Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

support nsconfig in webpack templates#1137

Open
farfromrefug wants to merge11 commits intoNativeScript:master
base:master
Choose a base branch
Loading
fromfarfromrefug:nsconfig_fix
Open
Show file tree
Hide file tree
Changes fromall 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: 17 additions & 1 deletionindex.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
const path = require("path");
const { existsSync } = require("fs");
const { existsSync, readFileSync } = require("fs");
const { ANDROID_APP_PATH } = require("./androidProjectHelpers");
const {
getPackageJson,
Expand DownExpand Up@@ -110,6 +110,22 @@ exports.getAppPath = (platform, projectDir) => {
}
};

exports.getNSConfigPaths = (projectDir, defaultAppPath, defaultAppResourcePath) => {
let appPath = defaultAppPath || "app";
let appResourcesPath = defaultAppResourcePath || "app/App_Resources";
const nsConfigPath = path.join(projectDir, 'nsconfig.json');
if (existsSync(nsConfigPath)) {
const nsConfig = readFileSync(nsConfigPath).toJSON();
if (nsConfig.appPath) {
appPath = nsConfig.appPath;
}
if (nsConfig.appResourcesPath) {
appResourcesPath = nsConfig.appResourcesPath;
}
}
return { appPath, appResourcesPath };
};

/**
* For backward compatibility. This method is deprecated. Do not use it anymore.
* This method also has a bug of not escaping valid regex symbols in entry path.
Expand Down
10 changes: 6 additions & 4 deletionstemplates/webpack.angular.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,12 +35,14 @@ module.exports = env => {
// Default destination inside platforms/<platform>/...
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));


const {
// The 'appPath' and 'appResourcesPath' values are fetched from
// the nsconfig.json configuration file.
appPath = "src",
appResourcesPath = "App_Resources",

// the nsconfig.json configuration file
appPath,
appResourcesPath
} = nsWebpack.getNSConfigPaths(projectRoot, "src")
const {
// You can provide the following flags when running 'tns run android|ios'
aot, // --env.aot
snapshot, // --env.snapshot,
Expand Down
1 change: 1 addition & 0 deletionstemplates/webpack.config.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@ const nativeScriptDevWebpack = {
WatchStateLoggerPlugin: EmptyClass,
PlatformFSPlugin: EmptyClass,
getAppPath: () => 'app',
getNSConfigPaths: () => ({ appPath: 'app', appResourcesPath: 'app/App_Resources' }),
getEntryModule: () => 'EntryModule',
hasRootLevelScopedModules: () => false,
hasRootLevelScopedAngular: () => false,
Expand Down
9 changes: 5 additions & 4 deletionstemplates/webpack.javascript.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,10 +35,11 @@ module.exports = env => {

const {
// The 'appPath' and 'appResourcesPath' values are fetched from
// the nsconfig.json configuration file.
appPath = "app",
appResourcesPath = "app/App_Resources",

// the nsconfig.json configuration file
appPath,
appResourcesPath
} = nsWebpack.getNSConfigPaths(projectRoot)
const {
// You can provide the following flags when running 'tns run android|ios'
snapshot, // --env.snapshot
production, // --env.production
Expand Down
9 changes: 5 additions & 4 deletionstemplates/webpack.typescript.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,10 +37,11 @@ module.exports = env => {

const {
// The 'appPath' and 'appResourcesPath' values are fetched from
// the nsconfig.json configuration file.
appPath = "app",
appResourcesPath = "app/App_Resources",

// the nsconfig.json configuration file
appPath,
appResourcesPath
} = nsWebpack.getNSConfigPaths(projectRoot)
const {
// You can provide the following flags when running 'tns run android|ios'
snapshot, // --env.snapshot
production, // --env.production
Expand Down
9 changes: 5 additions & 4 deletionstemplates/webpack.vue.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,10 +39,11 @@ module.exports = env => {

const {
// The 'appPath' and 'appResourcesPath' values are fetched from
// the nsconfig.json configuration file.
appPath = "app",
appResourcesPath = "app/App_Resources",

// the nsconfig.json configuration file
appPath,
appResourcesPath
} = nsWebpack.getNSConfigPaths(projectRoot)
const {
// You can provide the following flags when running 'tns run android|ios'
snapshot, // --env.snapshot
production, // --env.production
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp