-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
68 lines (62 loc) · 2.18 KB
/
webpack.prod.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
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
var WebpackMerge = require('webpack-merge');
var UglifyJSPlugin = require('uglifyjs-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var CompressionPlugin = require('compression-webpack-plugin');
var common = require('./webpack.common.js');
module.exports = WebpackMerge(common, {
plugins: [
new BundleTracker({filename: "./webpack-prod-stats.json"}),
new UglifyJSPlugin(),
new CleanWebpackPlugin(['frontend/bundles/*.*']),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new CompressionPlugin({
asset: "[path].jgz[query]",
algorithm: "gzip",
test: /\.js$/,
threshold: 10240,
minRatio: 0.8
}),
],
module: {
loaders: [
{
test: /\.(jpg|png|svg|woff|woff2|eot|ttf|svg|gif)$/,
loaders: [
{
loader: 'file-loader',
options: {
name: '[name]-[hash].[ext]',
hash: 'sha512',
digest: 'hex',
publicPath: '../static/bundles/'
}
},
{
loader: 'image-webpack-loader',
options: {
optipng: {
optimizationLevel: 7,
},
pngquant: {
quality: '80-85',
speed: 1
},
mozjpeg: {
progressive: true,
quality: 65
},
gifsicle: {
interlaced: true,
optimizationLevel: 3
},
}
}
],
}
]
}
});