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 Dotenv = require('dotenv-webpack')
|
|
|
|
const path = require('path')
|
2021-11-22 14:17:10 +03:00
|
|
|
const CompressionPlugin = require('compression-webpack-plugin')
|
2024-07-27 18:04:21 +03:00
|
|
|
const DefinePlugin = require('webpack').DefinePlugin
|
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'
|
2023-04-10 10:55:22 +03:00
|
|
|
const devProduction = (process.env.CLIENT_TYPE ?? '') === 'dev-production'
|
2024-07-27 18:04:21 +03:00
|
|
|
const devProductionHuly = (process.env.CLIENT_TYPE ?? '') === 'dev-huly'
|
|
|
|
const devProductionBold = (process.env.CLIENT_TYPE ?? '') === 'dev-bold'
|
|
|
|
const dev = (process.env.CLIENT_TYPE ?? '') === 'dev' || devServer || devProduction || devProductionHuly || devProductionBold
|
|
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
|
|
|
|
|
2024-02-16 09:20:03 +03:00
|
|
|
const { EsbuildPlugin } = require('esbuild-loader')
|
2021-08-05 02:31:54 +03:00
|
|
|
|
2024-02-23 08:37:22 +03:00
|
|
|
const doValidate = !prod || (process.env.DO_VALIDATE === 'true')
|
|
|
|
|
2024-07-27 18:04:21 +03:00
|
|
|
const useCache = process.env.USE_CACHE === 'true'
|
|
|
|
|
2023-02-09 19:50:30 +03:00
|
|
|
/**
|
|
|
|
* @type {Configuration}
|
|
|
|
*/
|
2024-04-16 09:54:29 +03:00
|
|
|
module.exports = [
|
|
|
|
{
|
|
|
|
mode: dev ? 'development' : mode,
|
|
|
|
entry: {
|
|
|
|
serviceWorker: '@hcengineering/notification/src/serviceWorker.ts'
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts$/,
|
|
|
|
exclude: /(node_modules|\.webpack)/,
|
|
|
|
use: {
|
|
|
|
loader: 'esbuild-loader',
|
|
|
|
options: {
|
|
|
|
target: 'es2021',
|
|
|
|
keepNames: true,
|
2024-09-02 19:11:39 +03:00
|
|
|
minify: prod,
|
2024-04-16 09:54:29 +03:00
|
|
|
sourcemap: !prod
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: __dirname + '/dist',
|
|
|
|
filename: '[name].js',
|
|
|
|
chunkFilename: '[name].js',
|
|
|
|
publicPath: '/',
|
|
|
|
pathinfo: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.ts', '.js'],
|
|
|
|
conditionNames: ['svelte', 'browser', 'import']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2024-07-27 18:04:21 +03:00
|
|
|
cache: useCache ? {
|
|
|
|
type: 'filesystem',
|
|
|
|
allowCollectingMemory: true,
|
|
|
|
cacheLocation: path.resolve(__dirname, '.build_dev'),
|
|
|
|
}: undefined,
|
2021-08-05 02:31:54 +03:00
|
|
|
entry: {
|
|
|
|
bundle: [
|
2022-09-21 11:08:25 +03:00
|
|
|
'@hcengineering/theme/styles/global.scss',
|
2024-02-23 08:37:22 +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: {
|
2023-11-20 13:01:43 +03:00
|
|
|
svelte: path.resolve('node_modules', 'svelte/src/runtime'),
|
|
|
|
'@hcengineering/platform-rig/profiles/ui/svelte': path.resolve('node_modules', 'svelte/src/runtime')
|
2023-01-04 20:58:54 +03:00
|
|
|
},
|
2024-02-23 08:37:22 +03:00
|
|
|
fallback: {
|
|
|
|
crypto: false
|
2021-08-05 02:31:54 +03:00
|
|
|
},
|
|
|
|
extensions: ['.mjs', '.js', '.svelte', '.ts'],
|
2023-10-07 13:38:21 +03:00
|
|
|
mainFields: ['svelte', 'browser', 'module', 'main'],
|
|
|
|
conditionNames: ['svelte', 'browser', 'import']
|
2021-08-05 02:31:54 +03:00
|
|
|
},
|
|
|
|
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
|
|
|
|
},
|
2024-07-27 18:04:21 +03:00
|
|
|
optimization: prod ? {
|
|
|
|
minimize: true,
|
2024-02-16 09:20:03 +03:00
|
|
|
minimizer: [
|
2024-07-27 18:04:21 +03:00
|
|
|
new EsbuildPlugin({ target: 'es2021' })
|
|
|
|
],
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
vendor: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
name: 'vendors',
|
|
|
|
chunks: 'all'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} : {
|
|
|
|
minimize: false,
|
|
|
|
mangleExports: false,
|
|
|
|
usedExports: false,
|
|
|
|
splitChunks: {
|
|
|
|
cacheGroups: {
|
|
|
|
vendor: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
|
|
|
name: 'vendors',
|
|
|
|
chunks: 'all'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-05 02:31:54 +03:00
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.ts?$/,
|
2024-02-23 08:37:22 +03:00
|
|
|
loader: 'esbuild-loader',
|
2023-02-09 19:50:30 +03:00
|
|
|
options: {
|
2024-02-21 19:11:41 +03:00
|
|
|
target: 'es2021',
|
|
|
|
keepNames: true,
|
2024-09-02 19:11:39 +03:00
|
|
|
minify: prod,
|
2024-07-27 18:04:21 +03:00
|
|
|
sourcemap: true
|
2023-02-09 19:50:30 +03:00
|
|
|
},
|
|
|
|
exclude: /node_modules/,
|
2021-08-05 02:31:54 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svelte$/,
|
2024-07-27 18:04:21 +03:00
|
|
|
use: [
|
|
|
|
{
|
2024-02-23 08:37:22 +03:00
|
|
|
loader: 'svelte-loader',
|
|
|
|
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,
|
2024-02-23 08:37:22 +03:00
|
|
|
preprocess: require('svelte-preprocess')({
|
2022-02-16 12:02:31 +03:00
|
|
|
postcss: true,
|
2024-07-27 18:04:21 +03:00
|
|
|
sourceMap: true,
|
2022-02-16 12:02:31 +03:00
|
|
|
}),
|
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,
|
|
|
|
}
|
2024-02-23 08:37:22 +03:00
|
|
|
}
|
2024-07-27 18:04:21 +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: {
|
2024-07-27 18:04:21 +03:00
|
|
|
name: 'fonts/[hash:base64:8].[ext]',
|
2021-08-05 02:31:54 +03:00
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2023-06-06 08:23:41 +03:00
|
|
|
test: /\.(jpg|png|webp|heic|avif)$/,
|
2021-08-05 02:31:54 +03:00
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2024-04-02 09:18:18 +03:00
|
|
|
name: 'img/[contenthash].[ext]',
|
2021-08-05 02:31:54 +03:00
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2024-07-11 17:40:57 +03:00
|
|
|
{
|
|
|
|
test: /\.(wav|ogg)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
'name': 'snd/[contenthash].[ext]',
|
|
|
|
esModule: false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2021-08-05 02:31:54 +03:00
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
2024-04-02 09:18:18 +03:00
|
|
|
name: 'img/[contenthash].[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: {
|
2024-11-09 15:23:28 +03:00
|
|
|
viewport: 'width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=1'
|
2022-10-20 05:43:05 +03:00
|
|
|
}
|
|
|
|
}),
|
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'
|
|
|
|
// }),
|
2024-02-23 08:37:22 +03:00
|
|
|
new Dotenv({ path: prod ? '.env-prod' : '.env' }),
|
2024-02-21 19:11:41 +03:00
|
|
|
new DefinePlugin({
|
|
|
|
'process.env.CLIENT_TYPE': JSON.stringify(process.env.CLIENT_TYPE)
|
2023-02-09 19:50:30 +03:00
|
|
|
}),
|
2024-02-23 08:37:22 +03:00
|
|
|
...(doValidate ? [
|
|
|
|
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
|
2024-10-09 08:08:27 +03:00
|
|
|
ignored: [
|
|
|
|
"**/node_modules",
|
|
|
|
"**/.git",
|
|
|
|
"**/common/temp",
|
|
|
|
"**/.rush",
|
|
|
|
"**/.rush/**",
|
|
|
|
"**/rush-logs",
|
|
|
|
"**/lib/*.js",
|
|
|
|
"**/lib/*.js.map",
|
|
|
|
"**/types/*.d.ts",
|
|
|
|
"**/.git/objects/**",
|
|
|
|
"**/node_modules/**",
|
|
|
|
"**/desktop/deploy/**",
|
|
|
|
"**/dist/**",
|
|
|
|
"**/.validate/**",
|
|
|
|
"**/.format/**",
|
|
|
|
"**/.build_dev/**"
|
|
|
|
],
|
2024-07-27 18:04:21 +03:00
|
|
|
aggregateTimeout: 100,
|
2024-10-09 08:08:27 +03:00
|
|
|
followSymlinks: false,
|
2024-07-27 18:04:21 +03:00
|
|
|
poll: 250
|
2023-02-09 19:50:30 +03:00
|
|
|
},
|
2024-07-27 18:04:21 +03:00
|
|
|
devtool: prod ? 'source-map' : 'eval-source-map', // '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
|
2024-02-23 08:37:22 +03:00
|
|
|
},
|
2024-07-27 18:04:21 +03:00
|
|
|
host: '0.0.0.0',
|
2024-11-13 10:53:46 +03:00
|
|
|
allowedHosts: 'all',
|
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
|
|
|
},
|
2024-07-27 18:04:21 +03:00
|
|
|
proxy: (devServer && !devProduction && !devProductionHuly && !devProductionBold) ? {
|
2021-11-22 14:17:10 +03:00
|
|
|
'/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'
|
|
|
|
},
|
2024-07-27 18:04:21 +03:00
|
|
|
'/api/v1': {
|
|
|
|
target: 'http://localhost:8087',
|
|
|
|
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'
|
|
|
|
},
|
2024-07-27 18:04:21 +03:00
|
|
|
'/rekoni/recognize': {
|
|
|
|
target: 'http://localhost:4004',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
}
|
|
|
|
} : !devProductionHuly && !devProductionBold ? {
|
2021-08-17 16:09:15 +03:00
|
|
|
'/account': {
|
2021-09-10 18:06:51 +03:00
|
|
|
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-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'
|
2024-07-27 18:04:21 +03:00
|
|
|
},
|
|
|
|
'/rekoni/recognize': {
|
|
|
|
target: 'https://rekoni.hc.enigneering',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
}
|
|
|
|
}: !devProductionBold ? {
|
|
|
|
'/account': {
|
|
|
|
target: 'https://account.huly.app/',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/account': '' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
|
|
|
'/api/v1': {
|
|
|
|
target: 'http://huly.app',
|
|
|
|
changeOrigin: true,
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
|
|
|
'/files': {
|
|
|
|
target: 'https://huly.app/files',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/files': '' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
|
|
|
'/rekoni/recognize': {
|
|
|
|
target: 'https://rekoni.huly.app',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
}
|
|
|
|
} : {
|
|
|
|
'/account': {
|
|
|
|
target: 'https://account.bold.ru/',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/account': '' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
|
|
|
'/files': {
|
|
|
|
target: 'https://app.bold.ru/files',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/files': '' },
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
|
|
|
'/api/v1': {
|
|
|
|
target: 'http://app.bold.ru',
|
|
|
|
changeOrigin: true,
|
|
|
|
logLevel: 'debug'
|
|
|
|
},
|
|
|
|
'/rekoni/recognize': {
|
|
|
|
target: 'https://rekoni.bold.ru',
|
|
|
|
changeOrigin: true,
|
|
|
|
pathRewrite: { '^/rekoni/recognize': '/recognize' },
|
|
|
|
logLevel: 'debug'
|
2022-02-16 12:02:31 +03:00
|
|
|
}
|
2021-08-05 02:31:54 +03:00
|
|
|
}
|
|
|
|
}
|
2024-04-16 09:54:29 +03:00
|
|
|
}]
|