-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
81 lines (76 loc) · 2.87 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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const env = process.env.NODE_ENV || 'development';
const isBuild = env === 'production' || process.env.BUILD;
const clean = list => list.filter(l => l);
const withBuild = module => (isBuild ? module : null);
module.exports = {
context: path.join(__dirname, './src'),
entry: {
app: './index.jsx'
},
output: {
publicPath: '/',
path: 'dist',
filename: '[name].[hash].js'
},
resolve: {
root: [path.resolve('./src'), path.resolve('./node_modules')],
extensions: ['', '.js', '.jsx']
},
devtool: isBuild ? 'source-map' : 'eval',
module: {
loaders: [
{ test: /\.jsx?$/, loaders: ['react-hot', 'babel'], exclude: /node_modules/ },
{ test: /\.html$/, loader: 'raw' },
{ test: /\.css$/, loader: 'style!css' },
{ test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' },
{ test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/font-woff' },
{ test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=application/octet-stream' },
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' },
{ test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'url?limit=10000&mimetype=image/svg+xml' },
{ test: /\.jpg$/, loader: 'url?limit=10000&minetype=image/jpg' },
{ test: /\.png$/, loader: 'url?limit=10000&minetype=image/png' },
{ test: /\.ico/, loader: 'url?limit=10000&minetype=image/x-icon' },
]
},
plugins: clean([
new webpack.DefinePlugin({
'process.env': { NODE_ENV: JSON.stringify(env) },
}),
new HtmlWebpackPlugin({
template: 'index.html',
inject: 'body',
minify: {
removeComments: true,
collapseWhitespace: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeStyleLinkTypeAttributes: true,
keepClosingSlash: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true
}
}),
withBuild(new webpack.optimize.OccurenceOrderPlugin()),
withBuild(new webpack.NoErrorsPlugin()),
withBuild(new webpack.optimize.DedupePlugin()),
withBuild(new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
screw_ie8: true,
warnings: false
},
mangle: {
screw_ie8: true,
},
output: {
screw_ie8: true,
comments: false
}
}))
])
};