Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): avoid attempted resolve of extern…
Browse files Browse the repository at this point in the history
…al CSS URLs with esbuild builder

When using the experimental esbuild-based browser application builder, `url()` functions within stylesheets
will no longer cause a build failure due to an attempted local file resolution of URLs that do not represent
on-disk resources. This includes absolute, protocol-relative, and root-relative URLs as well as SVG path
identifiers.

(cherry picked from commit 932a4f4)
  • Loading branch information
clydin authored and alan-agius4 committed Nov 8, 2022
1 parent 24770f4 commit 4cb27b8
Showing 1 changed file with 9 additions and 0 deletions.
Expand Up @@ -34,6 +34,15 @@ export function createCssResourcePlugin(): Plugin {
return null;
}

// If root-relative, absolute or protocol relative url, mark as external to leave the
// path/URL in place.
if (/^((?:\w+:)?\/\/|data:|chrome:|#|\/)/.test(args.path)) {
return {
path: args.path,
external: true,
};
}

const { importer, kind, resolveDir, namespace, pluginData = {} } = args;
pluginData[CSS_RESOURCE_RESOLUTION] = true;

Expand Down

0 comments on commit 4cb27b8

Please sign in to comment.