Skip to content

ESBuild builders inconsistent in importing CSS vs SCSS if both files exist #27147

@bgotink

Description

@bgotink

Command

build, serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

When resolving import paths, sass doesn't require the extension to be present. The esbuild builders (application and browser-esbuild) handle these extensions inconsistently, sometimes favouring CSS over Scss if both files exist, and sometimes the other way around.

Minimal Reproduction

  1. Clone https://github.com/bgotink/angular-repro-esbuild-scss-resolution
  2. npm ci
  3. npm exec ng build
  4. cat dist/test/browser/styles-*.css

Note the content of the CSS file is

:root{--file: resolve-test/test.css}:root{--file: local-test.scss}

indicating that for local files, .scss is favoured over .css, while for files imported from packages .css is favoured over .scss.

The webpack builder favours .scss over .css in both scenarios.

Exception or Error

No response

Your Environment

_                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 17.2.0
Node: 18.14.0
Package Manager: npm 9.3.1
OS: darwin arm64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1702.0
@angular-devkit/build-angular   17.2.0
@angular-devkit/core            17.2.0
@angular-devkit/schematics      17.2.0
@angular/cli                    17.2.0
@schematics/angular             17.2.0
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.4

Anything else relevant?

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