-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
86 lines (82 loc) · 1.71 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
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const webConfig = {
target: 'web',
mode: 'development',
entry: ['./src/index.js'],
output: {
libraryTarget: 'umd',
path: __dirname + '/dist',
filename: 'solid-ipfs-browser.js'
},
module: {
rules: [{
test: /\.json$/,
use: 'json-loader',
exclude: /node_modules/
},
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ["env", "stage-0"] // env --> es6, stage-0 --> es7, react --> react
}
},
exclude: /node_modules/
}
]
}
};
const webMinConfig = {
target: 'web',
mode: 'production',
entry: ['./src/index.js'],
output: {
libraryTarget: 'umd',
path: __dirname + '/dist',
filename: 'solid-ipfs-browser.min.js'
},
module: {
rules: [{
test: /\.json$/,
use: 'json-loader',
exclude: /node_modules/
},
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ["env", "stage-0"] // env --> es6, stage-0 --> es7, react --> react
}
},
exclude: /node_modules/
}
]
},
optimization: {
minimizer: [
new UglifyJsPlugin({
uglifyOptions: {
compress: {
// 在UglifyJs删除没有用到的代码时不输出警告
warnings: false,
// 删除所有的 `console` 语句,可以兼容ie浏览器
drop_console: true,
// 内嵌定义了但是只用到一次的变量
collapse_vars: true,
// 提取出出现多次但是没有定义成变量去引用的静态值
reduce_vars: true,
},
output: {
// 最紧凑的输出
beautify: false,
// 删除所有的注释
comments: false,
}
}
})
]
}
};
module.exports = [webConfig, webMinConfig];