@@ -7,7 +7,7 @@ const CleanWebpackPlugin = require("clean-webpack-plugin");
77const CopyWebpackPlugin = require ( "copy-webpack-plugin" ) ;
88const { BundleAnalyzerPlugin } = require ( "webpack-bundle-analyzer" ) ;
99const { NativeScriptWorkerPlugin } = require ( "nativescript-worker-loader/NativeScriptWorkerPlugin" ) ;
10- const UglifyJsPlugin = require ( "uglifyjs -webpack-plugin" ) ;
10+ const TerserPlugin = require ( "terser -webpack-plugin" ) ;
1111const hashSalt = Date . now ( ) . toString ( ) ;
1212
1313module . exports = env => {
@@ -41,21 +41,25 @@ module.exports = env => {
4141 uglify, // --env.uglify
4242 report, // --env.report
4343 sourceMap, // --env.sourceMap
44+ hiddenSourceMap, // --env.hiddenSourceMap
4445 hmr, // --env.hmr,
4546 unitTesting, // --env.unitTesting
4647 } = env ;
48+ const isAnySourceMapEnabled = ! ! sourceMap || ! ! hiddenSourceMap ;
4749 const externals = nsWebpack . getConvertedExternals ( env . externals ) ;
4850
4951 const appFullPath = resolve ( projectRoot , appPath ) ;
5052 const appResourcesFullPath = resolve ( projectRoot , appResourcesPath ) ;
5153
52- const entryModule = nsWebpack . getEntryModule ( appFullPath ) ;
54+ const entryModule = nsWebpack . getEntryModule ( appFullPath , platform ) ;
5355 const entryPath = `.${ sep } ${ entryModule } .ts` ;
5456 const entries = { bundle : entryPath } ;
5557 if ( platform === "ios" ) {
5658 entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules.js" ;
5759 } ;
5860
61+ let sourceMapFilename = nsWebpack . getSourceMapFilename ( hiddenSourceMap , __dirname , dist ) ;
62+
5963 const config = {
6064 mode : uglify ? "production" : "development" ,
6165 context : appFullPath ,
@@ -72,6 +76,7 @@ module.exports = env => {
7276 output : {
7377 pathinfo : false ,
7478 path : dist ,
79+ sourceMapFilename,
7580 libraryTarget : "commonjs2" ,
7681 filename : "[name].js" ,
7782 globalObject : "global" ,
@@ -104,7 +109,7 @@ module.exports = env => {
104109 "fs" : "empty" ,
105110 "__dirname" : false ,
106111 } ,
107- devtool : sourceMap ? "inline-source-map" : "none" ,
112+ devtool : hiddenSourceMap ? "hidden-source-map" : ( sourceMap ? "inline-source-map" : "none" ) ,
108113 optimization : {
109114 runtimeChunk : "single" ,
110115 splitChunks : {
@@ -124,12 +129,14 @@ module.exports = env => {
124129 } ,
125130 minimize : ! ! uglify ,
126131 minimizer : [
127- new UglifyJsPlugin ( {
132+ new TerserPlugin ( {
128133 parallel : true ,
129134 cache : true ,
130- uglifyOptions : {
135+ sourceMap : isAnySourceMapEnabled ,
136+ terserOptions : {
131137 output : {
132138 comments : false ,
139+ semicolons : ! isAnySourceMapEnabled
133140 } ,
134141 compress : {
135142 // The Android SBG has problems parsing the output
@@ -183,13 +190,13 @@ module.exports = env => {
183190
184191 {
185192 test : / \. c s s $ / ,
186- use : { loader : "css-loader" , options : { minimize : false , url : false } }
193+ use : { loader : "css-loader" , options : { url : false } }
187194 } ,
188195
189196 {
190197 test : / \. s c s s $ / ,
191198 use : [
192- { loader : "css-loader" , options : { minimize : false , url : false } } ,
199+ { loader : "css-loader" , options : { url : false } } ,
193200 "sass-loader"
194201 ]
195202 } ,
@@ -202,7 +209,7 @@ module.exports = env => {
202209 configFile : "tsconfig.tns.json" ,
203210 allowTsInNodeModules : true ,
204211 compilerOptions : {
205- sourceMap
212+ sourceMap : isAnySourceMapEnabled
206213 }
207214 } ,
208215 }
0 commit comments