1 |
|
2 | const webpack = require('webpack')
|
3 | const CompressionPlugin = require('compression-webpack-plugin')
|
4 | const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
|
5 | const ManifestPlugin = require('webpack-manifest-plugin')
|
6 | const UglifierSettings = require('./uglifier_settings')
|
7 |
|
8 | module.exports = ({ifProduction, ifDevelopment, keys, basePath})=>{
|
9 | return [
|
10 | new LodashModuleReplacementPlugin
|
11 | , new webpack.EnvironmentPlugin(keys)
|
12 | , new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/)
|
13 | , new ManifestPlugin({
|
14 | fileName: 'webpack-digest.json',
|
15 | publicPath: `${basePath}/`
|
16 | })
|
17 |
|
18 |
|
19 | , new webpack.LoaderOptionsPlugin(ifProduction(
|
20 | {
|
21 | minimize: true
|
22 | , debug: false
|
23 | }
|
24 | , {
|
25 | debug: true
|
26 | }
|
27 | ))
|
28 | , ifProduction(new webpack.optimize.UglifyJsPlugin(UglifierSettings))
|
29 | , ifProduction(new CompressionPlugin({
|
30 | asset: '[path].gz[query]',
|
31 | algorithm: 'gzip',
|
32 | test: /\.js$/
|
33 | }))
|
34 | , ifDevelopment(new webpack.HotModuleReplacementPlugin())
|
35 | ]
|
36 | }; |
\ | No newline at end of file |