diff options
author | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-11-01 22:42:19 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-11-01 14:42:19 +0100 |
commit | 8ae9bd0eea75a0a22c08e1e45b2136674aa88cf5 (patch) | |
tree | 5b0684e53e7a584136ba73f1fbafce4e5febcdd2 /config/webpack | |
parent | 5521e94e24bc0ce4258d612ea074334b2af85e54 (diff) |
Upgrade compression-webpack-plugin to version 1.0.1 (#5581)
Diffstat (limited to 'config/webpack')
-rw-r--r-- | config/webpack/production.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/config/webpack/production.js b/config/webpack/production.js index 6de79c811..e2d7f11dc 100644 --- a/config/webpack/production.js +++ b/config/webpack/production.js @@ -9,6 +9,16 @@ const OfflinePlugin = require('offline-plugin'); const { publicPath } = require('./configuration.js'); const path = require('path'); +let compressionAlgorithm; +try { + const zopfli = require('node-zopfli'); + compressionAlgorithm = (content, options, fn) => { + zopfli.gzip(content, options, fn); + }; +} catch (error) { + compressionAlgorithm = 'gzip'; +} + module.exports = merge(sharedConfig, { output: { filename: '[name]-[chunkhash].js', @@ -33,7 +43,7 @@ module.exports = merge(sharedConfig, { }), new CompressionPlugin({ asset: '[path].gz[query]', - algorithm: 'gzip', + algorithm: compressionAlgorithm, test: /\.(js|css|html|json|ico|svg|eot|otf|ttf)$/, }), new BundleAnalyzerPlugin({ // generates report.html and stats.json |