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

feat: use UglifyJsPlugin which support es6 code #401

Merged
merged 2 commits into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dependencyManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})) {
Expand Down
9 changes: 6 additions & 3 deletions templates/webpack.angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions templates/webpack.javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions templates/webpack.typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down