-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.production.config.js
61 lines (59 loc) · 1.57 KB
/
webpack.production.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
var HtmlWebpackPlugin = require('html-webpack-plugin')
var autoprefixer = require('autoprefixer-core');
var csswring = require('csswring');
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
var config = {
entry: './src/scripts/app.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: '[name].[hash].js'
},
module: {
preLoaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'eslint'
}],
loaders: [{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel'
}, {
test: /\.scss$/,
loader: 'style!css!postcss!sass'
}, {
test: /\.woff$|\.ttf$|\.wav$|\.mp3$/,
loader: 'file'
}, {
test: /\.jpe?g$|\.gif$|\.png$|\.svg$/,
loaders: [
'url?limit=8192&hash=sha512&digest=hex&name=[hash].[ext]',
'image?bypassOnDebug&optimizationLevel=7&interlaced=false'
]
}]
},
postcss: [autoprefixer, csswring],
plugins: [
new HtmlWebpackPlugin({
template: './src/template_index.html',
inject: 'body' // Inject all scripts into the body
}),
// removes a lot of debugging code in React
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}
}),
// keeps hashes consistent between compilations
new webpack.optimize.OccurenceOrderPlugin(),
// minifies your code
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
]
};
module.exports = config;