-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathwebpack.config.js
43 lines (38 loc) · 1.03 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
const webpack = require('webpack')
const join = require('path').join
const product = process.env.BABEL_ENV === 'product'
let filename = 'calc.js';
let path = join(__dirname, 'dist');
const plugins = []
const uglify = new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false, drop_console: true } })
if (product) {
plugins.push(uglify)
filename = 'calc.min.js'
path = join(__dirname, 'dist')
}
const config = {
context: __dirname,
entry: join(__dirname, 'src', 'index.js'),
output: {
path: path,
filename: filename,
library: 'calc',
libraryTarget: 'umd',
umdNamedDefine: true
},
plugins: plugins,
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
options: { // 参数
presets: ['es2015', 'stage-2'],
plugins: ['transform-runtime'],
}
}
]
},
}
module.exports = config