From e63e51e4fec6709f5177f0f815745b44035cce54 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 28 Dec 2022 12:02:10 -0500 Subject: [PATCH] fix(@angular-devkit/build-angular): ensure Sass load paths are resolved from workspace root When using the esbuild-based browser application builder, the Sass compiler will attempt to resolve any relative load paths from the current working directory. However, the load paths from the `angular.json` file should always be relative to the location of the `angular.json` which is considered the workspace root. While the current working directory is typically also the workspace root, it is not required nor always the same. To resolve this potential mismatch, the load paths are now resolved from the workspace root prior to being passed to the Sass compiler. --- .../src/builders/browser-esbuild/stylesheets.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/stylesheets.ts b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/stylesheets.ts index c4390e80fcfd..c1add3f73418 100644 --- a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/stylesheets.ts +++ b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/stylesheets.ts @@ -46,7 +46,10 @@ export function createStylesheetBundleOptions( plugins: [ createSassPlugin({ sourcemap: !!options.sourcemap, - loadPaths: options.includePaths, + // Ensure Sass load paths are absolute based on the workspace root + loadPaths: options.includePaths?.map((includePath) => + path.resolve(options.workspaceRoot, includePath), + ), inlineComponentData, }), createCssResourcePlugin(),