@@ -32,7 +32,6 @@ module.exports = env => {
3232
3333 // Default destination inside platforms/<platform>/...
3434 const dist = resolve ( projectRoot , nsWebpack . getAppPath ( platform , projectRoot ) ) ;
35- const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS" ;
3635
3736 const {
3837 // The 'appPath' and 'appResourcesPath' values are fetched from
@@ -43,13 +42,15 @@ module.exports = env => {
4342
4443 // You can provide the following flags when running 'tns run android|ios'
4544 aot, // --env.aot
46- snapshot, // --env.snapshot
45+ snapshot, // --env.snapshot,
46+ production, // --env.production
4747 uglify, // --env.uglify
4848 report, // --env.report
4949 sourceMap, // --env.sourceMap
5050 hiddenSourceMap, // --env.hiddenSourceMap
5151 hmr, // --env.hmr,
5252 unitTesting, // --env.unitTesting
53+ verbose, // --env.verbose
5354 } = env ;
5455
5556 const isAnySourceMapEnabled = ! ! sourceMap || ! ! hiddenSourceMap ;
@@ -60,8 +61,9 @@ module.exports = env => {
6061 const entryModule = `${ nsWebpack . getEntryModule ( appFullPath , platform ) } .ts` ;
6162 const entryPath = `.${ sep } ${ entryModule } ` ;
6263 const entries = { bundle : entryPath } ;
63- if ( platform === "ios" ) {
64- entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules.js" ;
64+ const areCoreModulesExternal = Array . isArray ( env . externals ) && env . externals . some ( e => e . indexOf ( "tns-core-modules" ) > - 1 ) ;
65+ if ( platform === "ios" && ! areCoreModulesExternal ) {
66+ entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules" ;
6567 } ;
6668
6769 const ngCompilerTransformers = [ ] ;
@@ -100,8 +102,15 @@ module.exports = env => {
100102
101103 let sourceMapFilename = nsWebpack . getSourceMapFilename ( hiddenSourceMap , __dirname , dist ) ;
102104
105+ const itemsToClean = [ `${ dist } /**/*` ] ;
106+ if ( platform === "android" ) {
107+ itemsToClean . push ( `${ join ( projectRoot , "platforms" , "android" , "app" , "src" , "main" , "assets" , "snapshots" ) } ` ) ;
108+ itemsToClean . push ( `${ join ( projectRoot , "platforms" , "android" , "app" , "build" , "configurations" , "nativescript-android-snapshot" ) } ` ) ;
109+ }
110+
111+ nsWebpack . processAppComponents ( appComponents , platform ) ;
103112 const config = {
104- mode : uglify ? "production" : "development" ,
113+ mode : production ? "production" : "development" ,
105114 context : appFullPath ,
106115 externals,
107116 watchOptions : {
@@ -204,6 +213,7 @@ module.exports = env => {
204213 unitTesting,
205214 appFullPath,
206215 projectRoot,
216+ ignoredFiles : nsWebpack . getUserDefinedEntries ( entries , platform )
207217 }
208218 } ,
209219 ] . filter ( loader => ! ! loader )
@@ -253,27 +263,17 @@ module.exports = env => {
253263 // Define useful constants like TNS_WEBPACK
254264 new webpack . DefinePlugin ( {
255265 "global.TNS_WEBPACK" : "true" ,
256- "process" : undefined ,
266+ "process" : "global.process" ,
257267 } ) ,
258268 // Remove all files from the out dir.
259- new CleanWebpackPlugin ( [ ` ${ dist } /**/*` ] ) ,
269+ new CleanWebpackPlugin ( itemsToClean , { verbose : ! ! verbose } ) ,
260270 // Copy assets to out dir. Add your own globs as needed.
261271 new CopyWebpackPlugin ( [
262272 { from : { glob : "fonts/**" } } ,
263273 { from : { glob : "**/*.jpg" } } ,
264274 { from : { glob : "**/*.png" } } ,
265275 ] , { ignore : [ `${ relative ( appPath , appResourcesFullPath ) } /**` ] } ) ,
266- // Generate a bundle starter script and activate it in package.json
267- new nsWebpack . GenerateBundleStarterPlugin (
268- // Don't include `runtime.js` when creating a snapshot. The plugin
269- // configures the WebPack runtime to be generated inside the snapshot
270- // module and no `runtime.js` module exist.
271- ( snapshot ? [ ] : [ "./runtime" ] )
272- . concat ( [
273- "./vendor" ,
274- "./bundle" ,
275- ] )
276- ) ,
276+ new nsWebpack . GenerateNativeScriptEntryPointsPlugin ( "bundle" ) ,
277277 // For instructions on how to set up workers with webpack
278278 // check out https://github.com/nativescript/worker-loader
279279 new NativeScriptWorkerPlugin ( ) ,
@@ -283,19 +283,6 @@ module.exports = env => {
283283 ] ,
284284 } ;
285285
286- // Copy the native app resources to the out dir
287- // only if doing a full build (tns run/build) and not previewing (tns preview)
288- if ( ! externals || externals . length === 0 ) {
289- config . plugins . push ( new CopyWebpackPlugin ( [
290- {
291- from : `${ appResourcesFullPath } /${ appResourcesPlatformDir } ` ,
292- to : `${ dist } /App_Resources/${ appResourcesPlatformDir } ` ,
293- context : projectRoot
294- } ,
295- ] ) ) ;
296- }
297-
298-
299286 if ( report ) {
300287 // Generate report files for bundles content
301288 config . plugins . push ( new BundleAnalyzerPlugin ( {
0 commit comments