Skip to content

Commit cb4691b

Browse files
Check for .css files when .less, .scss etc. are queried in style-scope (NativeScript#5128)
1 parent ec2ce7f commit cb4691b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

tns-core-modules/ui/styling/style-scope.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ class CSSSource {
9999
}
100100

101101
public static fromFile(url: string, keyframes: KeyframesMap): CSSSource {
102+
// .scss, .sass, etc. css files in vanilla app are usually compiled to .css so we will try to load a compiled file first.
103+
let cssFileUrl = url.replace(/\..\w+$/, ".css");
104+
if (cssFileUrl !== url) {
105+
const cssFile = CSSSource.resolveCSSPathFromURL(cssFileUrl);
106+
if (cssFile) {
107+
return new CSSSource(undefined, url, cssFile, keyframes, undefined);
108+
}
109+
}
110+
102111
const file = CSSSource.resolveCSSPathFromURL(url);
103112
return new CSSSource(undefined, url, file, keyframes, undefined);
104113
}
@@ -619,6 +628,9 @@ export function resolveFileNameFromUrl(url: string, appDirectory: string, fileEx
619628
}
620629

621630
if (!isAbsolutePath) {
631+
if (fileName[0] === "~" && fileName[1] !== "/" && fileName[1] !== "\"") {
632+
fileName = fileName.substr(1);
633+
}
622634
const external = path.join(appDirectory, "tns_modules", fileName);
623635
if (fileExists(external)) {
624636
return external;

0 commit comments

Comments
 (0)