-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathwebpack.dll.js
45 lines (43 loc) · 1.15 KB
/
webpack.dll.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
const path = require("path");
const TerserWebpackPlugin = require("terser-webpack-plugin");
const { DllPlugin } = require("webpack"); // 由于 vue-cli 内置了 webpack 所以不需要在 package.json 中声明
const { DLL_DIR } = require("./webpack.config");
module.exports = {
mode: "production",
devtool: "source-map",
entry: {
vue: ["vue"],
vuex: ["vuex"],
ELEMENT: ["element-ui"],
vueRouter: ["vue-router"],
axios: ["axios"]
},
output: {
path: path.resolve(__dirname, "./.dll"),
filename: "[name].dll.js",
// 库全局变量的名字,如何暴露模块
library: "[name]"
},
optimization: {
minimizer: [
// 删除类库文件中的log
new TerserWebpackPlugin({
sourceMap: true,
terserOptions: {
warnings: false,
compress: {
drop_debugger: true,
drop_console: true
}
}
})
]
},
plugins: [
new DllPlugin({
//必须和全局变量即library名字相同,否则DllPlugin插件找不到第三方库
name: "[name]",
path: path.join(__dirname, DLL_DIR, "/[name].manifest.json")
})
]
};