diff --git a/dependencyManager.js b/dependencyManager.js index cfe08499..d080bdd2 100644 --- a/dependencyManager.js +++ b/dependencyManager.js @@ -67,6 +67,7 @@ function getRequiredDeps(packageJson) { "nativescript-worker-loader": "~0.8.1", "resolve-url-loader": "~2.2.1", "extract-text-webpack-plugin": "~3.0.2", + "uglifyjs-webpack-plugin": "~1.1.6", }; if (isAngular({packageJson})) { diff --git a/templates/webpack.angular.js b/templates/webpack.angular.js index d7e86ce6..56434bcb 100644 --- a/templates/webpack.angular.js +++ b/templates/webpack.angular.js @@ -7,6 +7,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); +const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); module.exports = env => { const platform = env && (env.android && "android" || env.ios && "ios"); @@ -151,9 +152,11 @@ module.exports = env => { // Work around an Android issue by setting compress = false const compress = platform !== "android"; - config.plugins.push(new webpack.optimize.UglifyJsPlugin({ - mangle: { except: nsWebpack.uglifyMangleExcludes }, - compress, + config.plugins.push(new UglifyJsPlugin({ + uglifyOptions: { + mangle: { reserved: nsWebpack.uglifyMangleExcludes }, + compress, + } })); } return config; diff --git a/templates/webpack.javascript.js b/templates/webpack.javascript.js index d4bb5a42..73127aa4 100644 --- a/templates/webpack.javascript.js +++ b/templates/webpack.javascript.js @@ -6,6 +6,7 @@ const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target const CopyWebpackPlugin = require("copy-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); +const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); module.exports = env => { const platform = env && (env.android && "android" || env.ios && "ios"); @@ -129,9 +130,11 @@ module.exports = env => { // Work around an Android issue by setting compress = false const compress = platform !== "android"; - config.plugins.push(new webpack.optimize.UglifyJsPlugin({ - mangle: { except: nsWebpack.uglifyMangleExcludes }, - compress, + config.plugins.push(new UglifyJsPlugin({ + uglifyOptions: { + mangle: { reserved: nsWebpack.uglifyMangleExcludes }, + compress, + } })); } return config; diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index f485d56e..c0129d7b 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -6,6 +6,7 @@ const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target const CopyWebpackPlugin = require("copy-webpack-plugin"); const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); +const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); module.exports = env => { const platform = env && (env.android && "android" || env.ios && "ios"); @@ -131,9 +132,11 @@ module.exports = env => { // Work around an Android issue by setting compress = false const compress = platform !== "android"; - config.plugins.push(new webpack.optimize.UglifyJsPlugin({ - mangle: { except: nsWebpack.uglifyMangleExcludes }, - compress, + config.plugins.push(new UglifyJsPlugin({ + uglifyOptions: { + mangle: { reserved: nsWebpack.uglifyMangleExcludes }, + compress, + } })); } return config;