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

fix-next: copy only the target platform App Resources #466

Merged
merged 1 commit into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions templates/webpack.angular.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve, join } = require("path");
const { relative, resolve, join } = require("path");

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

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

const platforms = ["ios", "android"];
const {
// The 'appPath' and 'appResourcesDir' values are fetched from
// The 'appPath' and 'appResourcesPath' values are fetched from
// the nsconfig.json configuration file
// when bundling with `tns run android|ios --bundle`.
appPath = "app",
Expand Down Expand Up @@ -128,14 +129,21 @@ 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: `${appResourcesFullPath}/**`, context: projectRoot },
{ from: "fonts/**" },
{ from: "**/*.jpg" },
{ from: "**/*.png" },
{ from: "**/*.xml" },
]),
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
// Generate a bundle starter script and activate it in package.json
new nsWebpack.GenerateBundleStarterPlugin([
"./vendor",
Expand Down
16 changes: 12 additions & 4 deletions templates/webpack.javascript.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve, join } = require("path");
const { relative, resolve, join } = require("path");

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

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

const platforms = ["ios", "android"];
const {
// The 'appPath' and 'appResourcesPath' values are fetched from
// the nsconfig.json configuration file
Expand Down Expand Up @@ -111,14 +112,21 @@ 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: `${appResourcesFullPath}/**`, context: projectRoot },
{ from: "fonts/**" },
{ from: "**/*.jpg" },
{ from: "**/*.png" },
{ from: "**/*.xml" },
]),
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
// Generate a bundle starter script and activate it in package.json
new nsWebpack.GenerateBundleStarterPlugin([
"./vendor",
Expand Down
18 changes: 13 additions & 5 deletions templates/webpack.typescript.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { resolve, join } = require("path");
const { relative, resolve, join } = require("path");

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

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

const platforms = ["ios", "android"];
const {
// The 'appPath' and 'appResourcesDir' values are fetched from
// The 'appPath' and 'appResourcesPath' values are fetched from
// the nsconfig.json configuration file
// when bundling with `tns run android|ios --bundle`.
appPath = "app",
Expand Down Expand Up @@ -113,14 +114,21 @@ 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: `${appResourcesFullPath}/**`, context: projectRoot },
{ from: "fonts/**" },
{ from: "**/*.jpg" },
{ from: "**/*.png" },
{ from: "**/*.xml" },
]),
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
// Generate a bundle starter script and activate it in package.json
new nsWebpack.GenerateBundleStarterPlugin([
"./vendor",
Expand Down