Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit f926e40

Browse files
committed
fix-next: copy only the target platform App Resources
When building for Android the App_Resources for iOS should be copied to the dist directory and vice-versa.
1 parent 93fb1a3 commit f926e40

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

Diff for: templates/webpack.angular.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { resolve, join } = require("path");
1+
const { relative, resolve, join } = require("path");
22

33
const webpack = require("webpack");
44
const nsWebpack = require("nativescript-dev-webpack");
@@ -15,13 +15,14 @@ module.exports = env => {
1515
throw new Error("You need to provide a target platform!");
1616
}
1717

18+
const platforms = ["ios", "android"];
1819
const projectRoot = __dirname;
1920
// Default destination inside platforms/<platform>/...
2021
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform));
22+
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
2123

22-
const platforms = ["ios", "android"];
2324
const {
24-
// The 'appPath' and 'appResourcesDir' values are fetched from
25+
// The 'appPath' and 'appResourcesPath' values are fetched from
2526
// the nsconfig.json configuration file
2627
// when bundling with `tns run android|ios --bundle`.
2728
appPath = "app",
@@ -128,14 +129,21 @@ module.exports = env => {
128129
}),
129130
// Remove all files from the out dir.
130131
new CleanWebpackPlugin([ `${dist}/**/*` ]),
132+
// Copy native app resources to out dir.
133+
new CopyWebpackPlugin([
134+
{
135+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
136+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
137+
context: projectRoot
138+
},
139+
]),
131140
// Copy assets to out dir. Add your own globs as needed.
132141
new CopyWebpackPlugin([
133-
{ from: `${appResourcesFullPath}/**`, context: projectRoot },
134142
{ from: "fonts/**" },
135143
{ from: "**/*.jpg" },
136144
{ from: "**/*.png" },
137145
{ from: "**/*.xml" },
138-
]),
146+
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
139147
// Generate a bundle starter script and activate it in package.json
140148
new nsWebpack.GenerateBundleStarterPlugin([
141149
"./vendor",

Diff for: templates/webpack.javascript.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { resolve, join } = require("path");
1+
const { relative, resolve, join } = require("path");
22

33
const webpack = require("webpack");
44
const nsWebpack = require("nativescript-dev-webpack");
@@ -15,11 +15,12 @@ module.exports = env => {
1515
throw new Error("You need to provide a target platform!");
1616
}
1717

18+
const platforms = ["ios", "android"];
1819
const projectRoot = __dirname;
1920
// Default destination inside platforms/<platform>/...
2021
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform));
22+
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
2123

22-
const platforms = ["ios", "android"];
2324
const {
2425
// The 'appPath' and 'appResourcesPath' values are fetched from
2526
// the nsconfig.json configuration file
@@ -111,14 +112,21 @@ module.exports = env => {
111112
}),
112113
// Remove all files from the out dir.
113114
new CleanWebpackPlugin([ `${dist}/**/*` ]),
115+
// Copy native app resources to out dir.
116+
new CopyWebpackPlugin([
117+
{
118+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
119+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
120+
context: projectRoot
121+
},
122+
]),
114123
// Copy assets to out dir. Add your own globs as needed.
115124
new CopyWebpackPlugin([
116-
{ from: `${appResourcesFullPath}/**`, context: projectRoot },
117125
{ from: "fonts/**" },
118126
{ from: "**/*.jpg" },
119127
{ from: "**/*.png" },
120128
{ from: "**/*.xml" },
121-
]),
129+
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
122130
// Generate a bundle starter script and activate it in package.json
123131
new nsWebpack.GenerateBundleStarterPlugin([
124132
"./vendor",

Diff for: templates/webpack.typescript.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { resolve, join } = require("path");
1+
const { relative, resolve, join } = require("path");
22

33
const webpack = require("webpack");
44
const nsWebpack = require("nativescript-dev-webpack");
@@ -15,13 +15,14 @@ module.exports = env => {
1515
throw new Error("You need to provide a target platform!");
1616
}
1717

18+
const platforms = ["ios", "android"];
1819
const projectRoot = __dirname;
1920
// Default destination inside platforms/<platform>/...
2021
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform));
22+
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
2123

22-
const platforms = ["ios", "android"];
2324
const {
24-
// The 'appPath' and 'appResourcesDir' values are fetched from
25+
// The 'appPath' and 'appResourcesPath' values are fetched from
2526
// the nsconfig.json configuration file
2627
// when bundling with `tns run android|ios --bundle`.
2728
appPath = "app",
@@ -113,14 +114,21 @@ module.exports = env => {
113114
}),
114115
// Remove all files from the out dir.
115116
new CleanWebpackPlugin([ `${dist}/**/*` ]),
117+
// Copy native app resources to out dir.
118+
new CopyWebpackPlugin([
119+
{
120+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
121+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
122+
context: projectRoot
123+
},
124+
]),
116125
// Copy assets to out dir. Add your own globs as needed.
117126
new CopyWebpackPlugin([
118-
{ from: `${appResourcesFullPath}/**`, context: projectRoot },
119127
{ from: "fonts/**" },
120128
{ from: "**/*.jpg" },
121129
{ from: "**/*.png" },
122130
{ from: "**/*.xml" },
123-
]),
131+
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
124132
// Generate a bundle starter script and activate it in package.json
125133
new nsWebpack.GenerateBundleStarterPlugin([
126134
"./vendor",

0 commit comments

Comments
 (0)