-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.mjs
50 lines (47 loc) · 1.65 KB
/
webpack.config.mjs
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
import path from "path";
import { fileURLToPath } from "url";
import TerserPlugin from 'terser-webpack-plugin';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const isProduction = process.env.NODE_ENV == 'production';
const config = {
entry: './compiled.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'yamcsProto.cjs',
},
optimization: {
minimize: true, // Enable minimization
minimizer: [new TerserPlugin({
extractComments: false, // Removes comments
terserOptions: {
compress: {
drop_console: true, // Remove console logs
drop_debugger: true, // Remove debugger statements
pure_funcs: ['console.info', 'console.debug', 'console.warn'], // Remove specific console functions
passes: 2, // Run compressor 2 times
},
mangle: true, // Mangle variable and function names
}
})],
},
module: {
rules: [
{
test: /\.(js|mjs)$/i,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
plugins: [
'@babel/plugin-transform-modules-commonjs',
],
presets: [
['@babel/preset-env', { targets: "defaults" }]
]
}
}
}
],
},
};
export default { ...config, mode: isProduction ? 'production' : 'development' };