Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f1e2ceb

Browse files
committedMar 17, 2018
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 2e94056 commit f1e2ceb

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed
 

‎templates/webpack.angular.js

Lines changed: 13 additions & 4 deletions
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");
@@ -14,6 +14,9 @@ module.exports = env => {
1414
throw new Error("You need to provide a target platform!");
1515
}
1616
const platforms = ["ios", "android"];
17+
const projectRoot = __dirname;
18+
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
19+
1720
const {
1821
// The 'appPath' and 'appResourcesDir' values are fetched from
1922
// the nsconfig.json configuration file
@@ -31,7 +34,6 @@ module.exports = env => {
3134
} = env;
3235
const ngToolsWebpackOptions = { tsConfigPath: join(__dirname, "tsconfig.json") };
3336

34-
const projectRoot = __dirname;
3537
const appFullPath = resolve(projectRoot, appPath);
3638
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
3739

@@ -122,14 +124,21 @@ module.exports = env => {
122124
new webpack.DefinePlugin({
123125
"global.TNS_WEBPACK": "true",
124126
}),
127+
// Copy native app resources to out dir.
128+
new CopyWebpackPlugin([
129+
{
130+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
131+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
132+
context: projectRoot
133+
},
134+
]),
125135
// Copy assets to out dir. Add your own globs as needed.
126136
new CopyWebpackPlugin([
127-
{ from: `${appResourcesFullPath}/**`, context: projectRoot },
128137
{ from: "fonts/**" },
129138
{ from: "**/*.jpg" },
130139
{ from: "**/*.png" },
131140
{ from: "**/*.xml" },
132-
]),
141+
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
133142
// Generate a bundle starter script and activate it in package.json
134143
new nsWebpack.GenerateBundleStarterPlugin([
135144
"./vendor",

‎templates/webpack.javascript.js

Lines changed: 13 additions & 4 deletions
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");
@@ -14,6 +14,9 @@ module.exports = env => {
1414
throw new Error("You need to provide a target platform!");
1515
}
1616
const platforms = ["ios", "android"];
17+
const projectRoot = __dirname;
18+
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
19+
1720
const {
1821
// The 'appPath' and 'appResourcesPath' values are fetched from
1922
// the nsconfig.json configuration file
@@ -29,7 +32,6 @@ module.exports = env => {
2932
report,
3033
} = env;
3134

32-
const projectRoot = __dirname;
3335
const appFullPath = resolve(projectRoot, appPath);
3436
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
3537

@@ -105,14 +107,21 @@ module.exports = env => {
105107
new webpack.DefinePlugin({
106108
"global.TNS_WEBPACK": "true",
107109
}),
110+
// Copy native app resources to out dir.
111+
new CopyWebpackPlugin([
112+
{
113+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
114+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
115+
context: projectRoot
116+
},
117+
]),
108118
// Copy assets to out dir. Add your own globs as needed.
109119
new CopyWebpackPlugin([
110-
{ from: `${appResourcesFullPath}/**`, context: projectRoot },
111120
{ from: "fonts/**" },
112121
{ from: "**/*.jpg" },
113122
{ from: "**/*.png" },
114123
{ from: "**/*.xml" },
115-
]),
124+
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
116125
// Generate a bundle starter script and activate it in package.json
117126
new nsWebpack.GenerateBundleStarterPlugin([
118127
"./vendor",

‎templates/webpack.typescript.js

Lines changed: 13 additions & 4 deletions
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");
@@ -14,6 +14,9 @@ module.exports = env => {
1414
throw new Error("You need to provide a target platform!");
1515
}
1616
const platforms = ["ios", "android"];
17+
const projectRoot = __dirname;
18+
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
19+
1720
const {
1821
// The 'appPath' and 'appResourcesDir' values are fetched from
1922
// the nsconfig.json configuration file
@@ -29,7 +32,6 @@ module.exports = env => {
2932
report,
3033
} = env;
3134

32-
const projectRoot = __dirname;
3335
const appFullPath = resolve(projectRoot, appPath);
3436
const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
3537

@@ -107,14 +109,21 @@ module.exports = env => {
107109
new webpack.DefinePlugin({
108110
"global.TNS_WEBPACK": "true",
109111
}),
112+
// Copy native app resources to out dir.
113+
new CopyWebpackPlugin([
114+
{
115+
from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
116+
to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
117+
context: projectRoot
118+
},
119+
]),
110120
// Copy assets to out dir. Add your own globs as needed.
111121
new CopyWebpackPlugin([
112-
{ from: `${appResourcesFullPath}/**`, context: projectRoot },
113122
{ from: "fonts/**" },
114123
{ from: "**/*.jpg" },
115124
{ from: "**/*.png" },
116125
{ from: "**/*.xml" },
117-
]),
126+
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
118127
// Generate a bundle starter script and activate it in package.json
119128
new nsWebpack.GenerateBundleStarterPlugin([
120129
"./vendor",

0 commit comments

Comments
 (0)
This repository has been archived.