Skip to content

Commit dd1a2d0

Browse files
author
Vasil Chimev
authored
chore: update to angular 5 and nativescript-dev-webpack@0.9.0 (#31)
* chore: update to angular 5 and nativescript-dev-webpack@0.9.0 * chore: add app.module.ngfactory.d.ts file
1 parent 20c6f51 commit dd1a2d0

File tree

6 files changed

+29
-22
lines changed

6 files changed

+29
-22
lines changed

app/app.module.ngfactory.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/*
2+
* A dynamically generated module when compiled with AoT.
3+
*/
4+
export const AppModuleNgFactory: any;

app/vendor-platform.ios.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
// Workaround for bug in angular: https://github.com/angular/angular-cli/pull/8589/files
2-
(<any>global).noOp;
1+
// There is a bug in angular: https://github.com/angular/angular-cli/pull/8589/files
2+
// Legendary stuff, its webpack plugin pretty much doesn't work with empty TypeScript files in v1.8.3
3+
void 0;

app/vendor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Snapshot the ~/app.css and the theme
22
const application = require("application");
33
require("ui/styling/style-scope");
4-
global.registerModule("app.css", () => require("~/app.css"));
4+
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
5+
global.registerWebpackModules(appCssContext);
56
application.loadAppCss();
67

78
require("./vendor-platform");

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
"nativescript": {
77
"id": "org.nativescript.testsappng",
88
"tns-ios": {
9-
"version": "3.1.0"
9+
"version": "next"
1010
},
1111
"tns-android": {
12-
"version": "3.3.0"
12+
"version": "next"
1313
}
1414
},
1515
"dependencies": {
@@ -25,9 +25,9 @@
2525
"nativescript-intl": "~3.0.0",
2626
"nativescript-theme-core": "^1.0.4",
2727
"reflect-metadata": "~0.1.8",
28-
"rxjs": "5.5.2",
28+
"rxjs": "^5.5.0",
2929
"tns-core-modules": "next",
30-
"zone.js": "0.8.4"
30+
"zone.js": "^0.8.4"
3131
},
3232
"devDependencies": {
3333
"@angular/compiler-cli": "~5.0.0",
@@ -37,21 +37,21 @@
3737
"babylon": "6.17.0",
3838
"codelyzer": "^3.0.1",
3939
"copy-webpack-plugin": "~4.0.1",
40+
"css-loader": "~0.28.7",
4041
"extract-text-webpack-plugin": "~3.0.0",
4142
"filewalker": "^0.1.3",
4243
"lazy": "1.0.11",
4344
"nativescript-css-loader": "~0.26.0",
44-
"nativescript-dev-typescript": "^0.4.5",
45-
"nativescript-dev-webpack": "next",
45+
"nativescript-dev-typescript": "^0.6.0-2017-12-14-01",
46+
"nativescript-dev-webpack": "^0.10.0-2017-12-19-02",
47+
"nativescript-worker-loader": "~0.8.1",
4648
"raw-loader": "~0.5.1",
4749
"resolve-url-loader": "~2.1.0",
4850
"tslint": "^5.4.3",
4951
"typescript": "~2.4.2",
5052
"webpack": "~3.8.1",
51-
"webpack-sources": "~1.0.1",
5253
"webpack-bundle-analyzer": "^2.8.2",
53-
"nativescript-worker-loader": "~0.8.1",
54-
"css-loader": "~0.28.7"
54+
"webpack-sources": "~1.0.1"
5555
},
5656
"scripts": {
5757
"tslint": "tslint --config tslint.json 'app/**/*.ts'",

tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
},
2222
"exclude": [
2323
"node_modules",
24-
"platforms",
25-
"**/*.aot.ts"
24+
"platforms"
2625
]
2726
}

webpack.config.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = env => {
1414
throw new Error("You need to provide a target platform!");
1515
}
1616
const platforms = ["ios", "android"];
17-
const mainSheet = "app.css";
1817
const { snapshot, uglify, report, aot } = env;
1918
const ngToolsWebpackOptions = { tsConfigPath: aot ? "tsconfig.aot.json" : "tsconfig.json"};
2019

@@ -59,14 +58,17 @@ module.exports = env => {
5958
module: {
6059
rules: [
6160
{ test: /\.html$|\.xml$/, use: "raw-loader" },
62-
// Root stylesheet gets extracted with bundled dependencies
63-
{ test: new RegExp(mainSheet), use: "css-loader?url=false" },
64-
// Other CSS files get bundled using the raw loader
65-
{ test: /\.css$/, exclude: new RegExp(mainSheet), use: "raw-loader" },
66-
// SASS support
67-
{ test: /\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },
61+
62+
// tns-core-modules reads the app.css and its imports using css-loader
63+
{ test: /\/app\.css$/, use: "css-loader?url=false" },
64+
{ test: /\/app\.scss$/, use: ["css-loader?url=false", "sass-loader"] },
65+
66+
// Angular components reference css files and their imports using raw-loader
67+
{ test: /\.css$/, exclude: /\/app\.css$/, use: "raw-loader" },
68+
{ test: /\.scss$/, exclude: /\/app\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },
69+
6870
// Compile TypeScript files with ahead-of-time compiler.
69-
{ test: /.ts$/, loader: "@ngtools/webpack" },
71+
{ test: /.ts$/, use: ["nativescript-dev-webpack/moduleid-compat-loader", "@ngtools/webpack"] },
7072
],
7173
},
7274
plugins: [

0 commit comments

Comments
 (0)