Skip to content

Commit 9b52253

Browse files
committed
fix(@angular/cli): all styleUrls and templateUrl are relative
Fixes #5056.
1 parent 1e47657 commit 9b52253

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/@ngtools/webpack/src/loader.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@ function _removeModuleId(refactor: TypeScriptFileRefactor) {
262262

263263
function _getResourceRequest(element: ts.Expression, sourceFile: ts.SourceFile) {
264264
if (element.kind == ts.SyntaxKind.StringLiteral) {
265-
// if string, assume relative path unless it start with /
266-
return `'${loaderUtils.urlToRequest((element as ts.StringLiteral).text, '')}'`;
265+
const url = (element as ts.StringLiteral).text;
266+
// If the URL does not start with ./ or ../, prepends ./ to it.
267+
return `'${/^\.?\.\//.test(url) ? '' : './'}${url}'`;
267268
} else {
268269
// if not string, just use expression directly
269270
return element.getFullText(sourceFile);

0 commit comments

Comments
 (0)