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

Commit 787d442

Browse files
committed
refactor: use global.loadModule for Angular only and require.context for
non-ng apps
1 parent f1cad69 commit 787d442

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

bundle-config-loader.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = function(source) {
22
this.cacheable();
3-
const { registerPages = true, loadCss = true } = this.query;
3+
const { angular = false, loadCss = true } = this.query;
44

5-
if (registerPages) {
5+
if (!angular) {
66
source = `
77
require("nativescript-dev-webpack/register-modules");
88
${source}
@@ -11,7 +11,7 @@ module.exports = function(source) {
1111

1212
if (loadCss) {
1313
source = `
14-
require("nativescript-dev-webpack/load-application-css");
14+
require("nativescript-dev-webpack/load-application-css")(${angular});
1515
${source}
1616
`;
1717
}

load-application-css.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
const application = require("tns-core-modules/application");
2-
require("tns-core-modules/ui/styling/style-scope");
1+
module.exports = function(isAngular) {
2+
const application = require("tns-core-modules/application");
3+
require("tns-core-modules/ui/styling/style-scope");
34

4-
global.registerModule("./app.css", () => require("~/app"));
5-
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
6-
global.registerWebpackModules(appCssContext);
5+
if (isAngular) {
6+
global.registerModule("./app.css", () => require("~/app"));
7+
} else {
8+
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
9+
global.registerWebpackModules(appCssContext);
10+
}
711

8-
application.loadAppCss();
12+
application.loadAppCss();
13+
}
914

plugins/NativeScriptSnapshotPlugin/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ exports.NativeScriptSnapshotPlugin = (function() {
4545

4646
let snapshotEntryContent = "";
4747
if (includeApplicationCss) {
48-
snapshotEntryContent += `require("nativescript-dev-webpack/load-application-css");`;
48+
snapshotEntryContent += `require("nativescript-dev-webpack/load-application-css")(${options.angular});`;
4949
}
5050
snapshotEntryContent += [ ...requireModules, ...internalRequireModules]
5151
.map(mod => `require('${mod}')`).join(";");
@@ -155,3 +155,4 @@ exports.NativeScriptSnapshotPlugin = (function() {
155155

156156
return NativeScriptSnapshotPlugin;
157157
})();
158+

plugins/NativeScriptSnapshotPlugin/options.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"androidNdkPath": {
55
"type": "string"
66
},
7+
"angular": {
8+
"type": "boolean",
9+
"default": false
10+
},
711
"chunk": {
812
"type": "string"
913
},

0 commit comments

Comments
 (0)