-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.weight.cjs
48 lines (47 loc) · 1.27 KB
/
webpack.config.weight.cjs
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
//weight
// npx webpack --config webpack.config.weight.cjs
const path = require('path');
const nodeExternals = require('webpack-node-externals');
module.exports = {
mode: 'production'
,target: 'web',
bail: false,
//externals: [nodeExternals()], // removes node_modules from your final bundle
entry: './out/shared/WordWeight/Schemas/ngaq4/wordWeightMain.js', // make sure this matches the main root of your code
output: {
path: path.join(__dirname, 'bundle'), // this can be any path and directory you want
filename: 'weight.js',
},
optimization: {
minimize: true, // enabling this reduces file size and readability
emitOnErrors: true, // 在错误时仍然生成输出文件
usedExports: true, // 启用 Tree Shaking
sideEffects: false, // 通常情况下,只有纯函数库或特定功能模块才会将 sideEffects 设置为 false
// splitChunks: {
// chunks: 'all',
// },
},
resolve:{
alias:{
"@shared": path.resolve(__dirname, "out/shared/")
}
,extensions: ['.ts', '.js'], // 自动解析这些扩展名
}
,module: {
rules: [
{
test: /\.m?js/,
type: "javascript/auto",
sideEffects: false
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
sideEffects: false
},
]
}
,devtool: 'source-map',
};