@@ -32,7 +32,6 @@ module.exports = env => {
32
32
33
33
// Default destination inside platforms/<platform>/...
34
34
const dist = resolve ( projectRoot , nsWebpack . getAppPath ( platform , projectRoot ) ) ;
35
- const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS" ;
36
35
37
36
const {
38
37
// The 'appPath' and 'appResourcesPath' values are fetched from
@@ -43,13 +42,15 @@ module.exports = env => {
43
42
44
43
// You can provide the following flags when running 'tns run android|ios'
45
44
aot, // --env.aot
46
- snapshot, // --env.snapshot
45
+ snapshot, // --env.snapshot,
46
+ production, // --env.production
47
47
uglify, // --env.uglify
48
48
report, // --env.report
49
49
sourceMap, // --env.sourceMap
50
50
hiddenSourceMap, // --env.hiddenSourceMap
51
51
hmr, // --env.hmr,
52
52
unitTesting, // --env.unitTesting
53
+ verbose, // --env.verbose
53
54
} = env ;
54
55
55
56
const isAnySourceMapEnabled = ! ! sourceMap || ! ! hiddenSourceMap ;
@@ -60,8 +61,9 @@ module.exports = env => {
60
61
const entryModule = `${ nsWebpack . getEntryModule ( appFullPath , platform ) } .ts` ;
61
62
const entryPath = `.${ sep } ${ entryModule } ` ;
62
63
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" ;
65
67
} ;
66
68
67
69
const ngCompilerTransformers = [ ] ;
@@ -100,8 +102,15 @@ module.exports = env => {
100
102
101
103
let sourceMapFilename = nsWebpack . getSourceMapFilename ( hiddenSourceMap , __dirname , dist ) ;
102
104
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 ) ;
103
112
const config = {
104
- mode : uglify ? "production" : "development" ,
113
+ mode : production ? "production" : "development" ,
105
114
context : appFullPath ,
106
115
externals,
107
116
watchOptions : {
@@ -204,6 +213,7 @@ module.exports = env => {
204
213
unitTesting,
205
214
appFullPath,
206
215
projectRoot,
216
+ ignoredFiles : nsWebpack . getUserDefinedEntries ( entries , platform )
207
217
}
208
218
} ,
209
219
] . filter ( loader => ! ! loader )
@@ -253,27 +263,17 @@ module.exports = env => {
253
263
// Define useful constants like TNS_WEBPACK
254
264
new webpack . DefinePlugin ( {
255
265
"global.TNS_WEBPACK" : "true" ,
256
- "process" : undefined ,
266
+ "process" : "global.process" ,
257
267
} ) ,
258
268
// Remove all files from the out dir.
259
- new CleanWebpackPlugin ( [ ` ${ dist } /**/*` ] ) ,
269
+ new CleanWebpackPlugin ( itemsToClean , { verbose : ! ! verbose } ) ,
260
270
// Copy assets to out dir. Add your own globs as needed.
261
271
new CopyWebpackPlugin ( [
262
272
{ from : { glob : "fonts/**" } } ,
263
273
{ from : { glob : "**/*.jpg" } } ,
264
274
{ from : { glob : "**/*.png" } } ,
265
275
] , { 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" ) ,
277
277
// For instructions on how to set up workers with webpack
278
278
// check out https://github.com/nativescript/worker-loader
279
279
new NativeScriptWorkerPlugin ( ) ,
@@ -283,19 +283,6 @@ module.exports = env => {
283
283
] ,
284
284
} ;
285
285
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
-
299
286
if ( report ) {
300
287
// Generate report files for bundles content
301
288
config . plugins . push ( new BundleAnalyzerPlugin ( {
0 commit comments