-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathwebpack.config.js
120 lines (117 loc) · 3.27 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const pkg = require("./package.json");
const Path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const common = {
mode: "production",
// mode: "development",
devtool: false,
externals: ['vue'],
module: {
rules: [
// {
// test: /\.js$/,
// use: ["babel-loader"],
// },
{
test: /\.txt$/,
use: ["raw-loader"],
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint-loader',
options: {
// eslint options (if necessary)
},
},
],
},
plugins: [
// new BundleAnalyzerPlugin()
],
optimization: {
// 1. 这个配置必须
minimizer: [
new TerserPlugin({
// exclude: /vue-devtools/,
terserOptions: {
compress: {
// turn off flags with small gains to speed up minification
arrows: false,
collapse_vars: false,
comparisons: false,
computed_props: false,
hoist_funs: false,
hoist_props: false,
hoist_vars: false,
inline: false,
loops: false,
negate_iife: false,
properties: false,
reduce_funcs: false,
reduce_vars: false,
switches: false,
toplevel: false,
typeofs: false,
drop_console: process.env.NODE_ENV == 'production',
// a few flags with noticable gains/speed ratio
// numbers based on out of the box vendor bundle
booleans: true,
if_return: true,
sequences: true,
unused: true,
// required features to drop conditional branches
conditionals: true,
dead_code: true,
evaluate: true
},
mangle: {
safari10: true
}
},
parallel: true
})
],
},
devtool: "source-map", // 2. 这个配置必须
resolve: {
extensions: [".js", ".vue"],
alias: {
'@front': '@vue-devtools/app-frontend/src',
'@back': '@vue-devtools/app-backend-core/lib',
'@utils': '@vue-devtools/shared-utils/lib',
},
symlinks: false,
},
}
//build vconsole & eruda plugin both
module.exports = [
{
entry: {
vue_plugin: Path.resolve(__dirname, "./packages/vconsole/index.js")
},
output: {
path: process.env.NODE_ENV == 'production' ? Path.resolve(__dirname, "./packages/vconsole/dist") : Path.resolve(__dirname, "./dev/src/debug/vconsole/"),
filename: "[name].js",
library: "vueVconsoleDevtools",
libraryTarget: "umd",
umdNamedDefine: true,
globalObject: 'this',
},
...common,
},
{
entry: {
vue_plugin: Path.resolve(__dirname, "./packages/eruda/index.js")
},
output: {
path: process.env.NODE_ENV == 'production' ? Path.resolve(__dirname, "./packages/eruda/dist") : Path.resolve(__dirname, "./dev/src/debug/eruda/"),
filename: "[name].js",
library: "eruda_vue_devtools",
libraryTarget: "umd",
umdNamedDefine: true,
globalObject: 'this',
},
...common,
}]