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

Commit 7d60958

Browse files
committed
1 parent 76fe655 commit 7d60958

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Diff for: css2json-loader.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import { parse, Rule, SyntaxTree } from "tns-core-modules/css";
1+
import { parse, Import, Stylesheet } from "css";
22
import { loader } from "webpack";
33
import { getOptions } from "loader-utils";
44

5-
interface ImportRule extends Rule {
6-
import: string;
7-
}
8-
95
const betweenQuotesPattern = /('|")(.*?)\1/;
106
const unpackUrlPattern = /url\(([^\)]+)\)/;
117
const inlineLoader = "!nativescript-dev-webpack/css2json-loader?useForImports!"
@@ -33,18 +29,18 @@ const loader: loader.Loader = function (content: string, map) {
3329
this.callback(null, `${dependencies.join("\n")}module.exports = ${str};`, map);
3430
}
3531

36-
function getImportRules(ast: SyntaxTree): ImportRule[] {
32+
function getImportRules(ast: Stylesheet): Import[] {
3733
if (!ast || (<any>ast).type !== "stylesheet" || !ast.stylesheet) {
3834
return [];
3935
}
40-
return <ImportRule[]>ast.stylesheet.rules
36+
return <Import[]>ast.stylesheet.rules
4137
.filter(rule => rule.type === "import" && (<any>rule).import)
4238
}
4339

4440
/**
4541
* Extracts the url from import rule (ex. `url("./platform.css")`)
4642
*/
47-
function extractUrlFromRule(importRule: ImportRule): string {
43+
function extractUrlFromRule(importRule: Import): string {
4844
const urlValue = importRule.import;
4945

5046
const unpackedUrlMatch = urlValue.match(unpackUrlPattern);

Diff for: package.json

+2
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@angular-devkit/core": "8.2.0",
5151
"clean-webpack-plugin": "~1.0.0",
5252
"copy-webpack-plugin": "~4.6.0",
53+
"css": "2.2.1",
5354
"css-loader": "~2.1.1",
5455
"escape-string-regexp": "1.0.5",
5556
"fork-ts-checker-webpack-plugin": "2.0.0",
@@ -82,6 +83,7 @@
8283
"@angular/compiler-cli": "8.2.0",
8384
"@istanbuljs/nyc-config-typescript": "^0.1.3",
8485
"@ngtools/webpack": "8.2.0",
86+
"@types/css": "0.0.31",
8587
"@types/jasmine": "^3.3.7",
8688
"@types/loader-utils": "^1.1.3",
8789
"@types/node": "^10.12.12",

0 commit comments

Comments
 (0)