Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions packages/angular/build/src/tools/angular/angular-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,9 @@ export function createAngularCompilerHost(
host.resourceNameToFileName = function (resourceName, containingFile) {
const resolvedPath = nodePath.join(nodePath.dirname(containingFile), resourceName);

// All resource names that have HTML file extensions are assumed to be templates
if (resourceName.endsWith('.html') || !hostOptions.externalStylesheets) {
// All resource names that have template file extensions are assumed to be templates
// TODO: Update compiler to provide the resource type to avoid extension matching here.
if (!hostOptions.externalStylesheets || hasTemplateExtension(resolvedPath)) {
return resolvedPath;
}

Expand Down Expand Up @@ -248,3 +249,16 @@ export function createAngularCompilerHost(

return host;
}

function hasTemplateExtension(file: string): boolean {
const extension = nodePath.extname(file).toLowerCase();

switch (extension) {
case '.htm':
case '.html':
case '.svg':
return true;
}

return false;
}