From d64eab9dc92c6ac4519abaf4a8bc2676c2d6118f Mon Sep 17 00:00:00 2001 From: Daniel Sokil Date: Wed, 29 May 2019 05:02:00 -0400 Subject: [PATCH] fix: Add Terser to Build Process (#5) * Fix #3 * Fix #3 with a general solution * Clean Up * Add Terser to Optimize Prod Build * Add Terser options for Safari --- package.json | 1 + webpack.config.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index daefe4db..a174c558 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "mini-css-extract-plugin": "^0.6.0", "optimize-css-assets-webpack-plugin": "^5.0.1", "prop-types": "15.7.2", + "terser-webpack-plugin": "^1.3.0", "webpack": "4.30.0", "webpack-cli": "3.3.1", "webpack-dev-server": "3.3.1", diff --git a/webpack.config.js b/webpack.config.js index 28dfa73f..607b83d7 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,7 @@ const { join, resolve } = require('path') const MiniCssExtractPlugin = require('mini-css-extract-plugin') const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin') const JavaScriptObfuscator = require('webpack-obfuscator') +const TerserPlugin = require('terser-webpack-plugin') const { NODE_ENV } = process.env @@ -44,7 +45,18 @@ module.exports = { libraryTarget: 'window' }, optimization: { - minimizer: [new OptimizeCSSAssetsPlugin({})], + minimizer: [ + new OptimizeCSSAssetsPlugin({}), + new TerserPlugin({ + cache: true, + parallel: true, + terserOptions: { + safari10: true, + ie8: true, + ecma: 5 + } + }) + ], splitChunks: { cacheGroups: { styles: {