-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
49 lines (46 loc) · 1.31 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
const {resolve, join} = require('path')
const webpack = require('webpack')
module.exports = env => {
const libraryName = 'console.image'
const addPlugin = (add, plugin) => add ? plugin : undefined
const ifProd = plugin => addPlugin(env.prod, plugin)
const ifDev = plugin => addPlugin(env.dev, plugin)
const removeEmpty = array => array.filter(i => !!i)
return {
devtool: env.prod ? 'source-map' : 'eval',
entry: removeEmpty([
'./src/index.js',
]),
context: resolve(__dirname, ''),
output: {
path: join(__dirname, 'dist'),
filename: libraryName + (env.prod ? '.min.js' : '.js'),
publicPath: '',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
loaders: [
{ test: /\.js$/, loaders: ['babel-loader'], exclude: /node_modules/ },
{ test: /\.json$/, loaders: ["json-loader"], exclude: /node_modules/},
]
},
plugins: removeEmpty([
ifProd(new webpack.optimize.DedupePlugin()),
ifProd(new webpack.LoaderOptionsPlugin({
minimize : true,
debug: false
})),
ifProd(new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true,
warnings: false
}
})),
]),
resolve: {
extensions: ['.js', '.json']
}
}
}