-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.client.config.js
97 lines (95 loc) · 2.68 KB
/
webpack.client.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// webpack.client.config.js
import webpack from 'webpack';
import { resolve as _resolve } from "path";
import TerserPlugin from 'terser-webpack-plugin'
export default (env, argv) => {
const isDevelopment = argv.mode === 'development'
const buildDir = isDevelopment ? 'build-dev' : 'build';
return {
devtool: "source-map",
mode: argv.mode,
target: "web",
entry: './src/client/index.tsx',
output: {
filename: "bundle.[contenthash].js",
path: _resolve(`./${buildDir}/public`),
},
experiments: {
outputModule: true,
},
module: {
rules: [
{
test: /\.css$/i,
use: ["css-loader"],
},
{
test: /\.(png\|jpg\|gif\|avif\|\/otf\/|ttf)$/i,
loader: 'ignore-loader',
},
{
test: /\.(ts|tsx)$/,
exclude: [
/node_modules/,
/node_modules\/(dotenv|google-auth-library|formidable|dotenv|mongoose)/,
/node_modules\/(nodemailer|sync-fetch|uuid|ws|chokidar-cli|compression-webpack-plugin)/,
/node_modules\/(css-loader|esm|file-loader|jest|json-loader|mkdirp|ncp|node-loader)/,
/node_modules\/(nodemon|npm-run-all|style-loader|terser-webpack-plugin|ts-loader|ts-node)/,
/node_modules\/(tsconfig-paths|typescript|webpack|webpack-bundle-analyzer|webpack-cli)/,
/node_modules\/(webpack-dev-server|webpack-node-externals)/
],
use: ["ts-loader"],
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".jsx"],
},
optimization: {
emitOnErrors: false,
moduleIds: 'hashed',
minimize: true,
minimizer: [new TerserPlugin({
parallel: true,
terserOptions: {
compress: {
// Enable aggressive minification options
defaults: true,
arrows: true,
arguments: true,
module: true,
unused: true,
dead_code: true,
conditionals: true,
booleans: true,
loops: true,
passes: 5,
},
},
}),],
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
minSize: 30000,
maxSize: 1000000,
minChunks: 1,
maxAsyncRequests: 15,
maxInitialRequests: 3,
automaticNameDelimiter: '~',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all',
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
},
},
usedExports: true,
}
}
};