Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 34b1b9d

Browse files
authored
feat: use UglifyJsPlugin which support es6 code (#401)
* chore: add uglifyjs-webpack-plugin to project devDeps * refactor: update webpack templates to use UglifyJsPlugin
1 parent 8e1a5a6 commit 34b1b9d

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

Diff for: dependencyManager.js

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ function getRequiredDeps(packageJson) {
6767
"nativescript-worker-loader": "~0.8.1",
6868
"resolve-url-loader": "~2.2.1",
6969
"extract-text-webpack-plugin": "~3.0.2",
70+
"uglifyjs-webpack-plugin": "~1.1.6",
7071
};
7172

7273
if (isAngular({packageJson})) {

Diff for: templates/webpack.angular.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin");
77
const ExtractTextPlugin = require("extract-text-webpack-plugin");
88
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
99
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
10+
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
1011

1112
module.exports = env => {
1213
const platform = env && (env.android && "android" || env.ios && "ios");
@@ -151,9 +152,11 @@ module.exports = env => {
151152

152153
// Work around an Android issue by setting compress = false
153154
const compress = platform !== "android";
154-
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
155-
mangle: { except: nsWebpack.uglifyMangleExcludes },
156-
compress,
155+
config.plugins.push(new UglifyJsPlugin({
156+
uglifyOptions: {
157+
mangle: { reserved: nsWebpack.uglifyMangleExcludes },
158+
compress,
159+
}
157160
}));
158161
}
159162
return config;

Diff for: templates/webpack.javascript.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target
66
const CopyWebpackPlugin = require("copy-webpack-plugin");
77
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
88
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
9+
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
910

1011
module.exports = env => {
1112
const platform = env && (env.android && "android" || env.ios && "ios");
@@ -129,9 +130,11 @@ module.exports = env => {
129130

130131
// Work around an Android issue by setting compress = false
131132
const compress = platform !== "android";
132-
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
133-
mangle: { except: nsWebpack.uglifyMangleExcludes },
134-
compress,
133+
config.plugins.push(new UglifyJsPlugin({
134+
uglifyOptions: {
135+
mangle: { reserved: nsWebpack.uglifyMangleExcludes },
136+
compress,
137+
}
135138
}));
136139
}
137140
return config;

Diff for: templates/webpack.typescript.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target
66
const CopyWebpackPlugin = require("copy-webpack-plugin");
77
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
88
const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin");
9+
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
910

1011
module.exports = env => {
1112
const platform = env && (env.android && "android" || env.ios && "ios");
@@ -131,9 +132,11 @@ module.exports = env => {
131132

132133
// Work around an Android issue by setting compress = false
133134
const compress = platform !== "android";
134-
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
135-
mangle: { except: nsWebpack.uglifyMangleExcludes },
136-
compress,
135+
config.plugins.push(new UglifyJsPlugin({
136+
uglifyOptions: {
137+
mangle: { reserved: nsWebpack.uglifyMangleExcludes },
138+
compress,
139+
}
137140
}));
138141
}
139142
return config;

0 commit comments

Comments
 (0)