diff --git a/templates/webpack.angular.js b/templates/webpack.angular.js index d244b5d6..a10d2b96 100644 --- a/templates/webpack.angular.js +++ b/templates/webpack.angular.js @@ -243,14 +243,6 @@ module.exports = env => { }), // Remove all files from the out dir. new CleanWebpackPlugin([`${dist}/**/*`]), - // Copy native app resources to out dir. - new CopyWebpackPlugin([ - { - from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, - to: `${dist}/App_Resources/${appResourcesPlatformDir}`, - context: projectRoot - }, - ]), // Copy assets to out dir. Add your own globs as needed. new CopyWebpackPlugin([ { from: { glob: "fonts/**" } }, @@ -277,6 +269,18 @@ module.exports = env => { ], }; + // Copy the native app resources to the out dir + // only if doing a full build (tns run/build) and not previewing (tns preview) + if (!externals || externals.length === 0) { + config.plugins.push(new CopyWebpackPlugin([ + { + from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, + to: `${dist}/App_Resources/${appResourcesPlatformDir}`, + context: projectRoot + }, + ])); + } + if (report) { // Generate report files for bundles content diff --git a/templates/webpack.config.spec.ts b/templates/webpack.config.spec.ts index 74c6f41e..ee5a62dc 100644 --- a/templates/webpack.config.spec.ts +++ b/templates/webpack.config.spec.ts @@ -83,7 +83,8 @@ describe('webpack.config.js', () => { }); it('returns empty array when externals are not passed', () => { - const config = webpackConfig(getInput({ platform })); + const input = getInput({ platform }); + const config = webpackConfig(input); expect(config.externals).toEqual([]); }); diff --git a/templates/webpack.javascript.js b/templates/webpack.javascript.js index b2b6d3fa..c98cdad7 100644 --- a/templates/webpack.javascript.js +++ b/templates/webpack.javascript.js @@ -195,14 +195,6 @@ module.exports = env => { }), // Remove all files from the out dir. new CleanWebpackPlugin([ `${dist}/**/*` ]), - // Copy native app resources to out dir. - new CopyWebpackPlugin([ - { - from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, - to: `${dist}/App_Resources/${appResourcesPlatformDir}`, - context: projectRoot - }, - ]), // Copy assets to out dir. Add your own globs as needed. new CopyWebpackPlugin([ { from: { glob: "fonts/**" } }, @@ -232,6 +224,18 @@ module.exports = env => { ], }; + // Copy the native app resources to the out dir + // only if doing a full build (tns run/build) and not previewing (tns preview) + if (!externals || externals.length === 0) { + config.plugins.push(new CopyWebpackPlugin([ + { + from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, + to: `${dist}/App_Resources/${appResourcesPlatformDir}`, + context: projectRoot + }, + ])); + } + if (report) { // Generate report files for bundles content config.plugins.push(new BundleAnalyzerPlugin({ diff --git a/templates/webpack.typescript.js b/templates/webpack.typescript.js index 8f970251..ec088514 100644 --- a/templates/webpack.typescript.js +++ b/templates/webpack.typescript.js @@ -208,14 +208,6 @@ module.exports = env => { }), // Remove all files from the out dir. new CleanWebpackPlugin([ `${dist}/**/*` ]), - // Copy native app resources to out dir. - new CopyWebpackPlugin([ - { - from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, - to: `${dist}/App_Resources/${appResourcesPlatformDir}`, - context: projectRoot - }, - ]), // Copy assets to out dir. Add your own globs as needed. new CopyWebpackPlugin([ { from: { glob: "fonts/**" } }, @@ -245,6 +237,18 @@ module.exports = env => { ], }; + // Copy the native app resources to the out dir + // only if doing a full build (tns run/build) and not previewing (tns preview) + if (!externals || externals.length === 0) { + config.plugins.push(new CopyWebpackPlugin([ + { + from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, + to: `${dist}/App_Resources/${appResourcesPlatformDir}`, + context: projectRoot + }, + ])); + } + if (report) { // Generate report files for bundles content config.plugins.push(new BundleAnalyzerPlugin({ diff --git a/templates/webpack.vue.js b/templates/webpack.vue.js index def82f1a..4ad892d3 100644 --- a/templates/webpack.vue.js +++ b/templates/webpack.vue.js @@ -217,12 +217,6 @@ module.exports = env => { }), // Remove all files from the out dir. new CleanWebpackPlugin([`${dist}/**/*`]), - // Copy native app resources to out dir. - new CopyWebpackPlugin([{ - from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, - to: `${dist}/App_Resources/${appResourcesPlatformDir}`, - context: projectRoot, - }]), // Copy assets to out dir. Add your own globs as needed. new CopyWebpackPlugin([ { from: { glob: "fonts/**" } }, @@ -252,6 +246,18 @@ module.exports = env => { ], }; + // Copy the native app resources to the out dir + // only if doing a full build (tns run/build) and not previewing (tns preview) + if (!externals || externals.length === 0) { + config.plugins.push(new CopyWebpackPlugin([ + { + from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, + to: `${dist}/App_Resources/${appResourcesPlatformDir}`, + context: projectRoot + }, + ])); + } + if (report) { // Generate report files for bundles content config.plugins.push(new BundleAnalyzerPlugin({