-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
71 lines (69 loc) · 1.59 KB
/
webpack.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
const path = require('path');
const webpack = require('webpack');
const TerserPlugin = require("terser-webpack-plugin");
const mode = process.env.NODE_ENV || "production";
console.log("👉 MODE:", `\x1b[33m ${mode} \x1b[0m`);
if (mode === "production") {
//console.log = function () { };
module.exports = {
stats: 'minimal',
mode: 'production',
entry: './index.js',
target: ["webworker", "es2021"],
output: {
filename: 'worker.js',
path: path.join(__dirname, 'dist'),
module: true,
library: {
type: "module",
},
},
resolve: {
extensions: [".ts", ".js"],
modules: ['node_modules'],
},
experiments: {
outputModule: true,
},
optimization: {
mangleExports: 'size',
chunkIds: 'size',
removeEmptyChunks: true,
sideEffects: true,
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
format: {
comments: false,
},
compress: {
drop_console: true,
unused: true,
dead_code: true,
conditionals: true,
evaluate: true,
}
},
extractComments: false,
})
]
},
plugins: [
new webpack.ProgressPlugin(),
]
}
} else {
module.exports = {
stats: 'minimal',
mode: "development",
entry: './index.js',
target: "webworker",
devtool: "source-map",
output: {
filename: mode + '_worker.js',
path: path.join(__dirname, 'dist'),
clean: true,
}
}
}