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')
|
2024-02-21 19:11:41 +03:00
|
|
|
const DefinePlugin = require('webpack').DefinePlugin
|
2021-08-05 02:31:54 +03:00
|
|
|
const path = require('path')
|
|
|
|
const autoprefixer = require('autoprefixer')
|
2021-11-22 14:17:10 +03:00
|
|
|
const CompressionPlugin = require('compression-webpack-plugin')
|
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'
|
2023-04-10 10:55:22 +03:00
|
|
|
const devProduction = (process.env.CLIENT_TYPE ?? '') === 'dev-production'
|
|
|
|
const dev = (process.env.CLIENT_TYPE ?? '') === 'dev' || devServer || devProduction
|
2024-02-16 09:20:03 +03:00
|
|
|
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
|
|
|
|
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')
|
|
|
|
|
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,
|
|
|
|
minify: !prod,
|
|
|
|
sourcemap: !prod
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
output: {
|
|
|
|
path: __dirname + '/dist',
|
|
|
|
filename: '[name].js',
|
|
|
|
chunkFilename: '[name].js',
|
|
|
|
publicPath: '/',
|
|
|
|
pathinfo: false
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
extensions: ['.ts', '.js'],
|
|
|
|
conditionNames: ['svelte', 'browser', 'import']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
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
|
|
|
|
},
|
|
|
|
optimization: {
|
2024-02-16 09:20:03 +03:00
|
|
|
minimize: prod,
|
|
|
|
minimizer: [
|
|
|
|
new EsbuildPlugin({
|
|
|
|
target: 'es2021' // Syntax to transpile to (see options below for possible values)
|
|
|
|
})
|
|
|
|
]
|
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,
|
|
|
|
minify: !prod,
|
|
|
|
sourcemap: !prod
|
2023-02-09 19:50:30 +03:00
|
|
|
},
|
|
|
|
exclude: /node_modules/,
|
2021-08-05 02:31:54 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.svelte$/,
|
|
|
|
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,
|
|
|
|
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,
|
|
|
|
}
|
2024-02-23 08:37:22 +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-04-02 09:18:18 +03:00
|
|
|
name: 'fonts/[contenthash].[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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
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({
|
2024-01-24 10:41:33 +03:00
|
|
|
// favicon: './public/favicon.ico',
|
2022-10-20 05:43:05 +03:00
|
|
|
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'
|
|
|
|
// }),
|
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
|
|
|
|
ignored: /node_modules/,
|
2023-06-22 07:55:57 +03:00
|
|
|
aggregateTimeout: 500,
|
|
|
|
poll: 1000
|
2023-02-09 19:50:30 +03:00
|
|
|
},
|
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
|
2024-02-23 08:37:22 +03:00
|
|
|
},
|
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-02-23 08:37:22 +03:00
|
|
|
proxy: (devServer && !devProduction) ? {
|
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'
|
|
|
|
},
|
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://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'
|
2022-02-16 12:02:31 +03:00
|
|
|
}
|
2021-08-05 02:31:54 +03:00
|
|
|
}
|
|
|
|
}
|
2024-04-16 09:54:29 +03:00
|
|
|
}]
|