|
1 |
| -import { parse, Rule, SyntaxTree } from "tns-core-modules/css"; |
| 1 | +import { parse, Import, Stylesheet } from "css"; |
2 | 2 | import { loader } from "webpack";
|
3 | 3 | import { getOptions } from "loader-utils";
|
4 | 4 |
|
5 |
| -interface ImportRule extends Rule { |
6 |
| - import: string; |
7 |
| -} |
8 |
| - |
9 | 5 | const betweenQuotesPattern = /('|")(.*?)\1/;
|
10 | 6 | const unpackUrlPattern = /url\(([^\)]+)\)/;
|
11 | 7 | const inlineLoader = "!nativescript-dev-webpack/css2json-loader?useForImports!"
|
@@ -33,18 +29,18 @@ const loader: loader.Loader = function (content: string, map) {
|
33 | 29 | this.callback(null, `${dependencies.join("\n")}module.exports = ${str};`, map);
|
34 | 30 | }
|
35 | 31 |
|
36 |
| -function getImportRules(ast: SyntaxTree): ImportRule[] { |
| 32 | +function getImportRules(ast: Stylesheet): Import[] { |
37 | 33 | if (!ast || (<any>ast).type !== "stylesheet" || !ast.stylesheet) {
|
38 | 34 | return [];
|
39 | 35 | }
|
40 |
| - return <ImportRule[]>ast.stylesheet.rules |
| 36 | + return <Import[]>ast.stylesheet.rules |
41 | 37 | .filter(rule => rule.type === "import" && (<any>rule).import)
|
42 | 38 | }
|
43 | 39 |
|
44 | 40 | /**
|
45 | 41 | * Extracts the url from import rule (ex. `url("./platform.css")`)
|
46 | 42 | */
|
47 |
| -function extractUrlFromRule(importRule: ImportRule): string { |
| 43 | +function extractUrlFromRule(importRule: Import): string { |
48 | 44 | const urlValue = importRule.import;
|
49 | 45 |
|
50 | 46 | const unpackedUrlMatch = urlValue.match(unpackUrlPattern);
|
|
0 commit comments