UNPKG

1.45 kBJavaScriptView Raw
1var webpack = require('webpack');
2var webpackMerge = require('webpack-merge')
3var path = require('path');
4
5var root = path.resolve(__dirname, '../').replace(/\\/g, '/') + '/';
6var assetsRoot = root + 'dist/';
7var assetsSubDirectory = 'static/';
8var productionSourceMap = true;
9var productionGzip = false;
10
11var devWebpackConfig = require('../webpack.config.js');
12
13devWebpackConfig.plugins = [];
14
15var 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
39if (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
57module.exports = webpackMerge(devWebpackConfig, prodWebpackConfig);
\No newline at end of file