diff options
Diffstat (limited to 'config/webpack/production.js')
-rw-r--r-- | config/webpack/production.js | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/config/webpack/production.js b/config/webpack/production.js index 30147cfe3..d37e11792 100644 --- a/config/webpack/production.js +++ b/config/webpack/production.js @@ -3,6 +3,7 @@ const merge = require('webpack-merge'); const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const CompressionPlugin = require('compression-webpack-plugin'); +const zopfli = require('@gfx/zopfli'); const sharedConfig = require('./shared.js'); const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const OfflinePlugin = require('offline-plugin'); @@ -10,16 +11,6 @@ const { publicPath } = require('./configuration.js'); const path = require('path'); const { URL } = require('url'); -let compressionAlgorithm; -try { - const zopfli = require('node-zopfli'); - compressionAlgorithm = (content, options, fn) => { - zopfli.gzip(content, options, fn); - }; -} catch (error) { - compressionAlgorithm = 'gzip'; -} - let attachmentHost; if (process.env.S3_ENABLED === 'true') { @@ -69,7 +60,9 @@ module.exports = merge(sharedConfig, { plugins: [ new CompressionPlugin({ - algorithm: compressionAlgorithm, + algorithm(input, compressionOptions, callback) { + return zopfli.gzip(input, compressionOptions, callback); + }, test: /\.(js|css|html|json|ico|svg|eot|otf|ttf)$/, }), new BundleAnalyzerPlugin({ // generates report.html and stats.json |