Skip to content

Commit

Permalink
fix(vite-plugin-angular): support Windows path for templateUrl and st…
Browse files Browse the repository at this point in the history
…yleUrl (#799)
  • Loading branch information
nemu69 authored Dec 14, 2023
1 parent f98b370 commit c083461
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/vite-plugin-angular/src/lib/component-resolvers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { dirname, resolve } from 'path';
import { normalizePath } from 'vite';

const styleUrlsRE = /styleUrls\s*:\s*\[([^\[]*?)\]|styleUrl:\s*["'](.*?)["']/;
const templateUrlRE = /templateUrl:\s*["'](.*?)["']/g;
Expand Down Expand Up @@ -56,7 +57,9 @@ export class StyleUrlsResolver {
.split(',');

const styleUrls = styleUrlPaths.map((styleUrlPath) => {
return `${styleUrlPath}|${resolve(dirname(id), styleUrlPath)}`;
return `${styleUrlPath}|${normalizePath(
resolve(dirname(id), styleUrlPath)
)}`;
});

this.styleUrlsCache.set(matchedStyleUrls, { styleUrls, matchedStyleUrls });
Expand Down Expand Up @@ -94,7 +97,9 @@ export class TemplateUrlsResolver {
/templateUrl|\s|'|"|\:|,/g,
''
);
const templateUrlPath = resolve(dirname(id), resolvedTemplatePath);
const templateUrlPath = normalizePath(
resolve(dirname(id), resolvedTemplatePath).replace(/\\/g, '/')
);
templateUrlPaths.push(`${resolvedTemplatePath}|${templateUrlPath}`);
});
}
Expand Down

0 comments on commit c083461

Please sign in to comment.