@@ -28,7 +28,6 @@ module.exports = env => {
2828
2929 // Default destination inside platforms/<platform>/...
3030 const dist = resolve ( projectRoot , nsWebpack . getAppPath ( platform , projectRoot ) ) ;
31- const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS" ;
3231
3332 const {
3433 // The 'appPath' and 'appResourcesPath' values are fetched from
@@ -39,12 +38,14 @@ module.exports = env => {
3938
4039 // You can provide the following flags when running 'tns run android|ios'
4140 snapshot, // --env.snapshot
41+ production, // --env.production
4242 uglify, // --env.uglify
4343 report, // --env.report
4444 sourceMap, // --env.sourceMap
4545 hiddenSourceMap, // --env.hiddenSourceMap
4646 hmr, // --env.hmr,
47- unitTesting, // --env.unitTesting
47+ unitTesting, // --env.unitTesting,
48+ verbose, // --env.verbose
4849 } = env ;
4950 const isAnySourceMapEnabled = ! ! sourceMap || ! ! hiddenSourceMap ;
5051 const externals = nsWebpack . getConvertedExternals ( env . externals ) ;
@@ -58,14 +59,22 @@ module.exports = env => {
5859
5960 const tsConfigPath = resolve ( projectRoot , "tsconfig.tns.json" ) ;
6061
61- if ( platform === "ios" ) {
62- entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules.js" ;
62+ const areCoreModulesExternal = Array . isArray ( env . externals ) && env . externals . some ( e => e . indexOf ( "tns-core-modules" ) > - 1 ) ;
63+ if ( platform === "ios" && ! areCoreModulesExternal ) {
64+ entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules" ;
6365 } ;
6466
6567 let sourceMapFilename = nsWebpack . getSourceMapFilename ( hiddenSourceMap , __dirname , dist ) ;
6668
69+ const itemsToClean = [ `${ dist } /**/*` ] ;
70+ if ( platform === "android" ) {
71+ itemsToClean . push ( `${ join ( projectRoot , "platforms" , "android" , "app" , "src" , "main" , "assets" , "snapshots" ) } ` ) ;
72+ itemsToClean . push ( `${ join ( projectRoot , "platforms" , "android" , "app" , "build" , "configurations" , "nativescript-android-snapshot" ) } ` ) ;
73+ }
74+
75+ nsWebpack . processAppComponents ( appComponents , platform ) ;
6776 const config = {
68- mode : uglify ? "production" : "development" ,
77+ mode : production ? "production" : "development" ,
6978 context : appFullPath ,
7079 externals,
7180 watchOptions : {
@@ -170,24 +179,15 @@ module.exports = env => {
170179 unitTesting,
171180 appFullPath,
172181 projectRoot,
182+ ignoredFiles : nsWebpack . getUserDefinedEntries ( entries , platform )
173183 }
174184 } ,
175185 ] . filter ( loader => ! ! loader )
176186 } ,
177187
178188 {
179- test : / - p a g e \. t s $ / ,
180- use : "nativescript-dev-webpack/script-hot-loader"
181- } ,
182-
183- {
184- test : / \. ( c s s | s c s s ) $ / ,
185- use : "nativescript-dev-webpack/style-hot-loader"
186- } ,
187-
188- {
189- test : / \. ( h t m l | x m l ) $ / ,
190- use : "nativescript-dev-webpack/markup-hot-loader"
189+ test : / \. ( t s | c s s | s c s s | h t m l | x m l ) $ / ,
190+ use : "nativescript-dev-webpack/hmr/hot-loader"
191191 } ,
192192
193193 { test : / \. ( h t m l | x m l ) $ / , use : "nativescript-dev-webpack/xml-namespace-loader" } ,
@@ -228,28 +228,18 @@ module.exports = env => {
228228 // Define useful constants like TNS_WEBPACK
229229 new webpack . DefinePlugin ( {
230230 "global.TNS_WEBPACK" : "true" ,
231- "process" : undefined ,
231+ "process" : "global.process" ,
232232 } ) ,
233233 // Remove all files from the out dir.
234- new CleanWebpackPlugin ( [ ` ${ dist } /**/*` ] ) ,
234+ new CleanWebpackPlugin ( itemsToClean , { verbose : ! ! verbose } ) ,
235235 // Copy assets to out dir. Add your own globs as needed.
236236 new CopyWebpackPlugin ( [
237237 { from : { glob : "fonts/**" } } ,
238238 { from : { glob : "**/*.jpg" } } ,
239239 { from : { glob : "**/*.png" } } ,
240240 { from : { glob : "assets/*.cer" } } ,
241241 ] , { ignore : [ `${ relative ( appPath , appResourcesFullPath ) } /**` ] } ) ,
242- // Generate a bundle starter script and activate it in package.json
243- new nsWebpack . GenerateBundleStarterPlugin (
244- // Don't include `runtime.js` when creating a snapshot. The plugin
245- // configures the WebPack runtime to be generated inside the snapshot
246- // module and no `runtime.js` module exist.
247- ( snapshot ? [ ] : [ "./runtime" ] )
248- . concat ( [
249- "./vendor" ,
250- "./bundle" ,
251- ] )
252- ) ,
242+ new nsWebpack . GenerateNativeScriptEntryPointsPlugin ( "bundle" ) ,
253243 // For instructions on how to set up workers with webpack
254244 // check out https://github.com/nativescript/worker-loader
255245 new NativeScriptWorkerPlugin ( ) ,
@@ -270,18 +260,6 @@ module.exports = env => {
270260 ] ,
271261 } ;
272262
273- // Copy the native app resources to the out dir
274- // only if doing a full build (tns run/build) and not previewing (tns preview)
275- if ( ! externals || externals . length === 0 ) {
276- config . plugins . push ( new CopyWebpackPlugin ( [
277- {
278- from : `${ appResourcesFullPath } /${ appResourcesPlatformDir } ` ,
279- to : `${ dist } /App_Resources/${ appResourcesPlatformDir } ` ,
280- context : projectRoot
281- } ,
282- ] ) ) ;
283- }
284-
285263 if ( report ) {
286264 // Generate report files for bundles content
287265 config . plugins . push ( new BundleAnalyzerPlugin ( {
0 commit comments