@@ -47,6 +47,7 @@ module.exports = env => {
4747 report, // --env.report
4848 sourceMap, // --env.sourceMap
4949 hmr, // --env.hmr,
50+ unitTesting, // --env.unitTesting
5051 } = env ;
5152
5253 const externals = nsWebpack . getConvertedExternals ( env . externals ) ;
@@ -55,6 +56,11 @@ module.exports = env => {
5556 const tsConfigName = "tsconfig.tns.json" ;
5657 const entryModule = `${ nsWebpack . getEntryModule ( appFullPath ) } .ts` ;
5758 const entryPath = `.${ sep } ${ entryModule } ` ;
59+ const entries = { bundle : entryPath } ;
60+ if ( platform === "ios" ) {
61+ entries [ "tns_modules/tns-core-modules/inspector_modules" ] = "inspector_modules.js" ;
62+ } ;
63+
5864 const ngCompilerTransformers = [ ] ;
5965 const additionalLazyModuleResources = [ ] ;
6066 if ( aot ) {
@@ -101,9 +107,7 @@ module.exports = env => {
101107 ]
102108 } ,
103109 target : nativescriptTarget ,
104- entry : {
105- bundle : entryPath ,
106- } ,
110+ entry : entries ,
107111 output : {
108112 pathinfo : false ,
109113 path : dist ,
@@ -139,6 +143,7 @@ module.exports = env => {
139143 } ,
140144 devtool : sourceMap ? "inline-source-map" : "none" ,
141145 optimization : {
146+ runtimeChunk : "single" ,
142147 splitChunks : {
143148 cacheGroups : {
144149 vendor : {
@@ -175,7 +180,7 @@ module.exports = env => {
175180 module : {
176181 rules : [
177182 {
178- test : new RegExp ( entryPath ) ,
183+ test : nsWebpack . getEntryPathRegExp ( appFullPath , entryPath ) ,
179184 use : [
180185 // Require all Android app components
181186 platform === "android" && {
@@ -188,6 +193,9 @@ module.exports = env => {
188193 options : {
189194 angular : true ,
190195 loadCss : ! snapshot , // load the application css if in debug mode
196+ unitTesting,
197+ appFullPath,
198+ projectRoot,
191199 }
192200 } ,
193201 ] . filter ( loader => ! ! loader )
@@ -241,25 +249,23 @@ module.exports = env => {
241249 } ) ,
242250 // Remove all files from the out dir.
243251 new CleanWebpackPlugin ( [ `${ dist } /**/*` ] ) ,
244- // Copy native app resources to out dir.
245- new CopyWebpackPlugin ( [
246- {
247- from : `${ appResourcesFullPath } /${ appResourcesPlatformDir } ` ,
248- to : `${ dist } /App_Resources/${ appResourcesPlatformDir } ` ,
249- context : projectRoot
250- } ,
251- ] ) ,
252252 // Copy assets to out dir. Add your own globs as needed.
253253 new CopyWebpackPlugin ( [
254254 { from : { glob : "fonts/**" } } ,
255255 { from : { glob : "**/*.jpg" } } ,
256256 { from : { glob : "**/*.png" } } ,
257257 ] , { ignore : [ `${ relative ( appPath , appResourcesFullPath ) } /**` ] } ) ,
258258 // Generate a bundle starter script and activate it in package.json
259- new nsWebpack . GenerateBundleStarterPlugin ( [
260- "./vendor" ,
261- "./bundle" ,
262- ] ) ,
259+ new nsWebpack . GenerateBundleStarterPlugin (
260+ // Don't include `runtime.js` when creating a snapshot. The plugin
261+ // configures the WebPack runtime to be generated inside the snapshot
262+ // module and no `runtime.js` module exist.
263+ ( snapshot ? [ ] : [ "./runtime" ] )
264+ . concat ( [
265+ "./vendor" ,
266+ "./bundle" ,
267+ ] )
268+ ) ,
263269 // For instructions on how to set up workers with webpack
264270 // check out https://github.com/nativescript/worker-loader
265271 new NativeScriptWorkerPlugin ( ) ,
@@ -269,6 +275,18 @@ module.exports = env => {
269275 ] ,
270276 } ;
271277
278+ // Copy the native app resources to the out dir
279+ // only if doing a full build (tns run/build) and not previewing (tns preview)
280+ if ( ! externals || externals . length === 0 ) {
281+ config . plugins . push ( new CopyWebpackPlugin ( [
282+ {
283+ from : `${ appResourcesFullPath } /${ appResourcesPlatformDir } ` ,
284+ to : `${ dist } /App_Resources/${ appResourcesPlatformDir } ` ,
285+ context : projectRoot
286+ } ,
287+ ] ) ) ;
288+ }
289+
272290
273291 if ( report ) {
274292 // Generate report files for bundles content
0 commit comments