Skip to content

Commit

Permalink
fix(@angular/cli): all styleUrls and templateUrl are relative
Browse files Browse the repository at this point in the history
  • Loading branch information
hansl committed Mar 16, 2017
1 parent d94040b commit 1fab08d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/@ngtools/webpack/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ function _removeModuleId(refactor: TypeScriptFileRefactor) {

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

0 comments on commit 1fab08d

Please sign in to comment.