Skip to content

Commit

Permalink
Move from uglify-es to terser
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas101 committed Sep 20, 2018
1 parent 28809d4 commit fc61a3a
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 28 deletions.
218 changes: 210 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@
"dependencies": {
"@babel/cli": "7.1.0",
"@babel/core": "7.1.0",
"babel-loader": "8.0.2",
"@babel/plugin-proposal-class-properties": "7.1.0",
"@babel/plugin-proposal-decorators": "7.1.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.15",
"@babel/preset-env": "7.1.0",
"@babel/preset-react": "7.0.0",
"babel-loader": "8.0.2",
"babel-plugin-transform-react-remove-prop-types": "0.4.15",
"clean-webpack-plugin": "0.1.19",
"colors": "1.3.2",
"copy-webpack-plugin": "4.5.2",
Expand All @@ -83,8 +83,7 @@
"nyan-progress-webpack-plugin": "1.2.0",
"progress-bar-webpack-plugin": "1.11.0",
"style-loader": "0.23.0",
"uglify-es": "3.3.9",
"uglifyjs-webpack-plugin": "1.3.0",
"terser-webpack-plugin": "1.1.0",
"url-loader": "1.1.1",
"uuid": "3.3.2",
"webpack": "4.19.1",
Expand Down
4 changes: 2 additions & 2 deletions src/guestApi/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const OUT_DIR = path.join(BIN_DIR, 'guestApi')
const devRequire = (n) => require(path.join(ROOT_DIR, 'node_modules', n))
const webpackRequire = (n) => require(path.join(ROOT_DIR, 'webpack', n))

const UglifyJS = devRequire('uglify-es')
const Terser = devRequire('terser')
const CleanWebpackPlugin = devRequire('clean-webpack-plugin')
const CopyWebpackPlugin = devRequire('copy-webpack-plugin')
const { isProduction, isVerboseLog } = webpackRequire('Config')
Expand All @@ -30,7 +30,7 @@ module.exports = function (env) {
to: '',
force: true,
transform: isProduction ? (content, path) => {
const res = UglifyJS.minify(content.toString())
const res = Terser.minify(content.toString())
if (res.error) {
throw res.error
} else {
Expand Down
20 changes: 11 additions & 9 deletions webpack/ElectronRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { isProduction } = require('./Config')
const ROOT_DIR = path.resolve(path.join(__dirname, '../'))
const devRequire = (n) => require(path.join(ROOT_DIR, 'node_modules', n))
const webpack = devRequire('webpack')
const UglifyJsPlugin = devRequire('uglifyjs-webpack-plugin')
const TerserPlugin = require('terser-webpack-plugin')

/**
* @param packagePath: the root path of the package
Expand All @@ -17,7 +17,16 @@ module.exports = function (packagePath, config) {
config.node.__filename = false

config.optimization = config.optimization || {}
config.optimization.minimize = false
config.optimization.minimizer = [
new TerserPlugin({
terserOptions: {
compress: {
reduce_vars: false // Enabling me seems to remove shouldComponentUpdate etc
}
}
})
]
config.optimization.minimize = isProduction

// Plugins
config.plugins = config.plugins || []
Expand All @@ -27,13 +36,6 @@ module.exports = function (packagePath, config) {
__DEV__: false,
'process.env.NODE_ENV': JSON.stringify('production')
}))
config.plugins.push(new UglifyJsPlugin({
uglifyOptions: {
compress: {
reduce_vars: false // Enabling me seems to remove shouldComponentUpdate etc
}
}
}))
}

// Resolve
Expand Down
Loading

0 comments on commit fc61a3a

Please sign in to comment.