diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js index ad8750c..f07b337 100644 --- a/build/webpack.prod.conf.js +++ b/build/webpack.prod.conf.js @@ -12,6 +12,8 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin') const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin') const UglifyJsPlugin = require('uglifyjs-webpack-plugin') const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin +const CompressionPlugin = require('compression-webpack-plugin'); +const productionGzipExtensions = ['js', 'css'] const env = require('../config/prod.env') @@ -57,6 +59,12 @@ const webpackConfig = merge(baseWebpackConfig, { sourceMap: config.build.productionSourceMap, parallel: true }), + new CompressionPlugin({ + algorithm: 'gzip', + test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'), + threshold: 10240, + minRatio: 0.8 + }), // extract css into its own file new ExtractTextPlugin({ filename: utils.assetsPath('css/[name].[contenthash].css'), diff --git a/package-lock.json b/package-lock.json index 95a96c4..206d954 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2515,6 +2515,19 @@ } } }, + "compression-webpack-plugin": { + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/compression-webpack-plugin/-/compression-webpack-plugin-1.1.12.tgz", + "integrity": "sha512-UpBXSHbrCSdSZieAffqXlAQpLO2fikVVRYibrWlbHYzKpOw1Y4jwkVZ/+S91GzWuJvXSbc8SBy/e8fQJh8uEMQ==", + "dev": true, + "requires": { + "cacache": "^10.0.1", + "find-cache-dir": "^1.0.0", + "neo-async": "^2.5.0", + "serialize-javascript": "^1.4.0", + "webpack-sources": "^1.0.1" + } + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", diff --git a/package.json b/package.json index 8366ebd..f12b837 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "babel-preset-env": "^1.3.2", "babel-preset-stage-2": "^6.22.0", "chalk": "^2.0.1", + "compression-webpack-plugin": "^1.1.12", "copy-webpack-plugin": "^4.0.1", "css-loader": "^0.28.11", "d3": "^7.3.0", diff --git a/src/index.html b/src/index.html index 73e98be..1b0d686 100644 --- a/src/index.html +++ b/src/index.html @@ -6,7 +6,7 @@