-
Notifications
You must be signed in to change notification settings - Fork 11
/
webpack.config.js
66 lines (60 loc) · 1.41 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
var webpack = require('webpack')
var path = require('path')
var OfflinePlugin = require('offline-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
const env = process.env.NODE_ENV
const production = env === 'prod'
var offline_plugin = new OfflinePlugin({
version: () => {
return process.env.VERSION
},
ServiceWorker: false,
AppCache: {
directory: '/'
}
})
var config = {
devtool: production ? 'source-map' : 'eval-source-maps',
entry: './index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{ test: /\.css$/, loader: 'style-loader!css-loader' },
{ test: /\.png$/, loader: 'url-loader?limit=100000' }
]
}
}
if (production) {
config.plugins = [
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
offline_plugin,
new HtmlWebpackPlugin({
hash: !!process.env.DEV,
template: 'index.html',
favicon: 'favicon.png'
})
]
}
module.exports = config