Skip to content

Sass files not correctly compiled with new ESBuild #25216

@AStoker

Description

@AStoker

Which @angular/* package(s) are the source of the bug?

compiler-cli

Is this a regression?

Yes

Description

When Angular now compiles with the ESBuild option (using Angular 16), sass files no longer import external resources (using the url) correctly.
Essentially, behavior is such that if a Sass file (let's call it module A) imports another sass file (let's call it module B), and module B lives in a different directory than Module A, and Module B uses a url to point to a relative file (like a font file), when Sass compiles everything into a single Sass file, the url that's used from Module B remains the same (which is relative to the original Module B location), resulting in errors around resolving file locations (because the compiled file doesn't have the same file location as the original).
Original behavior didn't care about this, and the compiled output correctly brought linked files up and changed the url paths.
While ESBuild is called a "drop-in" replacement, this needs to be resolved.

Please provide a link to a minimal reproduction of the bug

https://github.com/AStoker/esbuild-font-import

Please provide the exception or error you saw

X [ERROR] Could not resolve "../webfonts/ShadowsIntoLight-Regular.ttf" [plugin angular-css-resource]

    src/styles.scss:6:11:
      6 │   src: url("../webfonts/ShadowsIntoLight-Regular.ttf") format("true...
        ╵            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 16.0.1
Node: 18.15.0
Package Manager: yarn 1.22.19
OS: win32 x64

Angular: 16.0.1
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1600.1
@angular-devkit/build-angular   16.0.1
@angular-devkit/core            16.0.1
@angular-devkit/schematics      16.0.1
@schematics/angular             16.0.1
rxjs                            7.8.1
typescript                      5.0.4

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions