1 | var webpack = require('webpack');
|
2 | var webpackMerge = require('webpack-merge')
|
3 | var path = require('path');
|
4 |
|
5 | var root = path.resolve(__dirname, '../').replace(/\\/g, '/') + '/';
|
6 | var assetsRoot = root + 'dist/';
|
7 | var assetsSubDirectory = 'static/';
|
8 | var productionSourceMap = true;
|
9 | var productionGzip = false;
|
10 |
|
11 | var devWebpackConfig = require('../webpack.config.js');
|
12 |
|
13 | devWebpackConfig.plugins = [];
|
14 |
|
15 | var prodWebpackConfig = {
|
16 | devtool: productionSourceMap ? '#source-map' : false,
|
17 | entry : root + "/src/index.js",
|
18 | output: {
|
19 | path: assetsRoot,
|
20 | library: 'match',
|
21 | libraryTarget: 'amd',
|
22 | filename: "bundle.js"
|
23 | },
|
24 | plugins: [
|
25 | new webpack.DefinePlugin({
|
26 | 'process.env': {
|
27 | NODE_ENV: '"production"'
|
28 | }
|
29 | }),
|
30 | new webpack.optimize.UglifyJsPlugin({
|
31 | compress: {
|
32 | warnings: false
|
33 | }
|
34 | }),
|
35 | new webpack.optimize.OccurenceOrderPlugin()
|
36 | ]
|
37 | };
|
38 |
|
39 | if (productionGzip) {
|
40 | var CompressionWebpackPlugin = require('compression-webpack-plugin')
|
41 |
|
42 | webpackConfig.plugins.push(
|
43 | new CompressionWebpackPlugin({
|
44 | asset: '[path].gz[query]',
|
45 | algorithm: 'gzip',
|
46 | test: new RegExp(
|
47 | '\\.(' +
|
48 | config.build.productionGzipExtensions.join('|') +
|
49 | ')$'
|
50 | ),
|
51 | threshold: 10240,
|
52 | minRatio: 0.8
|
53 | })
|
54 | )
|
55 | }
|
56 |
|
57 | module.exports = webpackMerge(devWebpackConfig, prodWebpackConfig); |
\ | No newline at end of file |