@import with Sass causes errors with browser-esbuild and application builders #26653
Closed
1 task done
Labels
angular/build:application
area: @angular-devkit/build-angular
freq1: low
Only reported by a handful of users who observe it rarely
severity3: broken
type: bug/fix
Command
build
Is this a regression?
The previous version in which this bug was not present was
No response
Description
If you use an import without referencing anything in the scss file, the import statement gets included in the generated component styles, which results in a 404 when you load the app. As soon as you reference something, this issue goes away and the styles are properly generated.
Below is a snippet of the generated bundle with the issue, and after referencing a variable in the imported scss.
Nothing referenced, import statement included (which causes the 404 error)
Variable referenced, works as expected
Minimal Reproduction
Here's a reprod (steps below taken to create: https://github.com/ryanrivest/sass-issue-reprod). To reproduce, you just need to run:
npm install
npm run build
npx http-server .\dist\sass-output-issue\browser\ -a localhost -p 4200
As soon as you load up the app, you should see 404 errors in the output:
If you uncomment the following from the
app.component.scss
, the error will go away.Steps taken to create reprod:
ng new sass-output-issue
, select SCSSapp.component.scss
to include this line:@import "variables";
sass
folder, and add a_variables.scss
file that defines some variablesangular.json
to include this folder:Exception or Error
Your Environment
Anything else relevant?
ng serve
.browser
builder.The text was updated successfully, but these errors were encountered: