2021-08-05 02:31:54 +03:00
|
|
|
//
|
|
|
|
// Copyright © 2020 Anticrm Platform Contributors.
|
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
|
|
const Dotenv = require('dotenv-webpack')
|
|
|
|
const path = require('path')
|
|
|
|
const autoprefixer = require('autoprefixer')
|
2021-11-22 14:17:10 +03:00
|
|
|
const CompressionPlugin = require('compression-webpack-plugin')
|
|
|
|
const DefinePlugin = require('webpack').DefinePlugin
|
2022-02-07 12:21:32 +03:00
|
|
|
const { resolve } = require('path')
|
2022-03-14 12:03:44 +03:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2023-02-09 19:50:30 +03:00
|
|
|
const { Configuration } = require('webpack')
|
2021-08-05 02:31:54 +03:00
|
|
|
|
|
|
|
const mode = process.env.NODE_ENV || 'development'
|
|
|
|
const prod = mode === 'production'
|
2021-11-22 14:17:10 +03:00
|
|
|
const devServer = (process.env.CLIENT_TYPE ?? '') === 'dev-server'
|
2021-11-27 15:20:20 +03:00
|
|
|
const dev = (process.env.CLIENT_TYPE ?? '') === 'dev' || devServer
|
2023-02-09 19:50:30 +03:00
|
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
2021-08-05 02:31:54 +03:00
|
|
|
|
2023-02-09 19:50:30 +03:00
|
|
|
/**
|
|
|
|
* @type {Configuration}
|
|
|
|
*/
|
2021-08-05 02:31:54 +03:00
|
|
|
module.exports = {
|
|
|
|
entry: {
|
|
|
|
bundle: [
|
2022-09-21 11:08:25 +03:00
|
|
|
'@hcengineering/theme/styles/global.scss',
|
2022-02-07 12:21:32 +03:00
|
|
|
...(dev ? ['./src/main-dev.ts']: ['./src/main.ts'] ),
|
2021-08-05 02:31:54 +03:00
|
|
|
]
|
|
|
|
},
|
2022-12-24 22:16:09 +03:00
|
|
|
ignoreWarnings: [
|
|
|
|
{
|
|
|
|
message: /a11y-/,
|
|
|
|
},
|
|
|
|
/warning from compiler/,
|
|
|
|
(warning) => true,
|
|
|
|
],
|
2021-08-05 02:31:54 +03:00
|
|
|
resolve: {
|
|
|
|
symlinks: true,
|
|
|
|
alias: {
|
2022-06-03 19:44:11 +03:00
|
|
|
svelte: path.resolve('./node_modules', 'svelte'),
|
2023-01-04 20:58:54 +03:00
|
|
|
'@hcengineering/platform-rig/profiles/ui/svelte': path.resolve('./node_modules', 'svelte'),
|
|
|
|
},
|
|
|
|
fallback: {
|
|
|
|
crypto: false
|
2021-08-05 02:31:54 +03:00
|
|
|
},
|
|
|
|
extensions: ['.mjs', '.js', '.svelte', '.ts'],
|
|
|
|
mainFields: ['svelte', 'browser', 'module', 'main']
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: __dirname + '/dist',
|
2022-03-14 12:03:44 +03:00
|
|
|
filename: '[name].[contenthash].js',
|
|
|
|
chunkFilename: '[name].[contenthash].js',
|
2023-02-09 19:50:30 +03:00
|
|
|
publicPath: '/',
|
|
|
|
pathinfo: false
|
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
minimize: prod
|
2021-08-05 02:31:54 +03:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts?$/,
|
2023-02-09 19:50:30 +03:00
|
|
|
loader:'ts-loader',
|
|
|
|
options: {
|
|
|
|
transpileOnly: true
|
|
|
|
},
|
|
|
|
exclude: /node_modules/,
|
2021-08-05 02:31:54 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svelte$/,
|
|
|
|
use: {
|
2022-02-03 12:03:53 +03:00
|
|
|
loader: 'svelte-loader',
|
2021-08-05 02:31:54 +03:00
|
|
|
options: {
|
2022-02-03 12:03:53 +03:00
|
|
|
compilerOptions: {
|
2022-02-07 12:21:32 +03:00
|
|
|
dev: !prod
|
2022-02-03 12:03:53 +03:00
|
|
|
},
|
2021-08-05 02:31:54 +03:00
|
|
|
emitCss: true,
|
2022-02-07 12:21:32 +03:00
|
|
|
hotReload: !prod,
|
2022-02-16 12:02:31 +03:00
|
|
|
preprocess: require('svelte-preprocess')({
|
|
|
|
postcss: true,
|
|
|
|
sourceMap: !prod,
|
|
|
|
}),
|
2022-02-07 12:21:32 +03:00
|
|
|
hotOptions: {
|
|
|
|
// Prevent preserving local component state
|
|
|
|
preserveLocalState: true,
|
|
|
|
|
|
|
|
// If this string appears anywhere in your component's code, then local
|
|
|
|
// state won't be preserved, even when noPreserveState is false
|
|
|
|
noPreserveStateKey: '@!hmr',
|
|
|
|
|
|
|
|
// Prevent doing a full reload on next HMR update after fatal error
|
|
|
|
noReload: true,
|
|
|
|
|
|
|
|
// Try to recover after runtime errors in component init
|
|
|
|
optimistic: false,
|
|
|
|
|
|
|
|
// --- Advanced ---
|
|
|
|
|
|
|
|
// Prevent adding an HMR accept handler to components with
|
|
|
|
// accessors option to true, or to components with named exports
|
|
|
|
// (from <script context="module">). This have the effect of
|
|
|
|
// recreating the consumer of those components, instead of the
|
|
|
|
// component themselves, on HMR updates. This might be needed to
|
|
|
|
// reflect changes to accessors / named exports in the parents,
|
|
|
|
// depending on how you use them.
|
|
|
|
acceptAccessors: true,
|
|
|
|
acceptNamedExports: true,
|
|
|
|
}
|
2022-02-03 12:03:53 +03:00
|
|
|
}
|
2021-08-05 02:31:54 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
2022-03-01 06:31:47 +03:00
|
|
|
// prod ? MiniCssExtractPlugin.loader :
|
|
|
|
'style-loader',
|
2021-08-05 02:31:54 +03:00
|
|
|
'css-loader',
|
|
|
|
'postcss-loader'
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
use: [
|
2022-03-01 06:31:47 +03:00
|
|
|
// prod ? MiniCssExtractPlugin.loader :
|
|
|
|
'style-loader',
|
2021-08-05 02:31:54 +03:00
|
|
|
'css-loader',
|
|
|
|
'postcss-loader',
|
|
|
|
'sass-loader',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
test: /\.(ttf|otf|eot|woff|woff2)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2021-08-06 10:41:02 +03:00
|
|
|
name: 'fonts/[hash:base64:8].[ext]',
|
2021-08-05 02:31:54 +03:00
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(jpg|png)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2021-08-06 10:41:02 +03:00
|
|
|
name: 'img/[hash:base64:8].[ext]',
|
2021-08-05 02:31:54 +03:00
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2021-08-06 10:41:02 +03:00
|
|
|
name: 'img/[hash:base64:8].[ext]',
|
2021-08-05 02:31:54 +03:00
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'svgo-loader',
|
|
|
|
options: {
|
|
|
|
plugins: [
|
|
|
|
{ name: 'removeHiddenElems', active: false }
|
|
|
|
// { removeHiddenElems: { displayNone: false } },
|
|
|
|
// { cleanupIDs: false },
|
|
|
|
// { removeTitle: true }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
mode,
|
|
|
|
plugins: [
|
2022-10-20 05:43:05 +03:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
meta: {
|
|
|
|
viewport: 'width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=1'
|
|
|
|
}
|
|
|
|
}),
|
2021-11-22 14:17:10 +03:00
|
|
|
...(prod ? [new CompressionPlugin()] : []),
|
2022-03-01 06:31:47 +03:00
|
|
|
// new MiniCssExtractPlugin({
|
|
|
|
// filename: '[name].[id][contenthash].css'
|
|
|
|
// }),
|
2021-11-22 14:17:10 +03:00
|
|
|
new Dotenv({path: prod ? '.env-prod' : '.env'}),
|
|
|
|
new DefinePlugin({
|
|
|
|
'process.env.CLIENT_TYPE': JSON.stringify(process.env.CLIENT_TYPE)
|
2023-02-09 19:50:30 +03:00
|
|
|
}),
|
|
|
|
new ForkTsCheckerWebpackPlugin()
|
2021-08-05 02:31:54 +03:00
|
|
|
],
|
2023-02-09 19:50:30 +03:00
|
|
|
watchOptions: {
|
|
|
|
// for some systems, watching many files can result in a lot of CPU or memory usage
|
|
|
|
// https://webpack.js.org/configuration/watch/#watchoptionsignored
|
|
|
|
// don't use this pattern, if you have a monorepo with linked packages
|
|
|
|
ignored: /node_modules/,
|
|
|
|
},
|
2022-02-07 12:21:32 +03:00
|
|
|
devtool: prod ? false : 'inline-source-map',
|
2021-08-05 02:31:54 +03:00
|
|
|
devServer: {
|
2022-02-07 12:21:32 +03:00
|
|
|
static: {
|
|
|
|
directory: path.resolve(__dirname, "public"),
|
|
|
|
publicPath: "/",
|
|
|
|
serveIndex: true,
|
|
|
|
watch: true,
|
|
|
|
},
|
2021-08-05 02:31:54 +03:00
|
|
|
historyApiFallback: {
|
|
|
|
disableDotRule: true
|
2022-02-07 12:21:32 +03:00
|
|
|
},
|
|
|
|
hot: true,
|
|
|
|
client: {
|
|
|
|
logging: "info",
|
2023-01-04 20:58:54 +03:00
|
|
|
overlay: true,
|
2022-02-07 12:21:32 +03:00
|
|
|
progress: false,
|
2021-08-08 15:52:05 +03:00
|
|
|
},
|
2021-11-22 14:17:10 +03:00
|
|
|
proxy: devServer ? {
|
|
|
|
'/account': {
|
|
|
|
target: 'http://localhost:3000',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/account': '' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
|
|
|
'/files': {
|
2022-09-09 06:44:33 +03:00
|
|
|
target: 'http://localhost:8087',
|
2021-11-22 14:17:10 +03:00
|
|
|
changeOrigin: true,
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
2022-02-16 12:02:31 +03:00
|
|
|
'/import': {
|
2022-09-09 06:44:33 +03:00
|
|
|
target: 'http://localhost:8087',
|
2022-02-16 12:02:31 +03:00
|
|
|
changeOrigin: true,
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
2021-11-22 14:17:10 +03:00
|
|
|
} : {
|
2021-08-17 16:09:15 +03:00
|
|
|
'/account': {
|
2021-09-10 18:06:51 +03:00
|
|
|
// target: 'https://ftwm71rwag.execute-api.us-west-2.amazonaws.com/stage/',
|
|
|
|
target: 'https://account.hc.engineering/',
|
2021-08-08 15:52:05 +03:00
|
|
|
changeOrigin: true,
|
2021-08-17 16:09:15 +03:00
|
|
|
pathRewrite: { '^/account': '' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
2021-11-22 14:17:10 +03:00
|
|
|
'/files': {
|
2021-08-28 13:05:36 +03:00
|
|
|
// target: 'https://anticrm-upload.herokuapp.com/',
|
2021-11-22 14:17:10 +03:00
|
|
|
// target: 'http://localhost:3000/',
|
2021-10-25 18:11:48 +03:00
|
|
|
target: 'https://front.hc.engineering/files',
|
2021-08-17 16:09:15 +03:00
|
|
|
changeOrigin: true,
|
2021-11-22 14:17:10 +03:00
|
|
|
pathRewrite: { '^/files': '' },
|
2021-08-08 15:52:05 +03:00
|
|
|
logLevel: 'debug'
|
2022-02-16 12:02:31 +03:00
|
|
|
}
|
2021-08-05 02:31:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|