You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Angular 15 fails with scss errors when building with browser:es-build #24467
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 trying to use es-build I get the following errors. Tried the solution specified in #24356, but it didn't work for me. Also found #24271 and other related issues, but still no luck.
[ERROR] [plugin angular-sass] Can't find stylesheet to import.
╷
1 │ @use'colors'as*;
│ ^^^^^^^^^^^^^^^^^^
╵
src/app/ng-modules/containers/organization-management/containers/user-roles/dialogs/user-roles-modal.component.scss 1:1 root stylesheet
✘ [ERROR] [plugin angular-sass] Error: The "path" argument must be of type string. Received an instance of TypeError
╷
3 │ @use'globals'asg;
│ ^^^^^^^^^^^^^^^^^^^
╵
src/styles/components/_mat-form-field.scss 3:1 @importsrc/styles/styles.scss9:9rootstylesheetangular:styles/global:styles:4:8:
4 │ @import'src/styles/styles.scss';
╵ ~~~~~~~~~~~~~~~~~~~~~~~~
Can you provide the current value of the includePaths option for the project as well as the location of the global and colors files relative to the workspace root (the location of the angular.json file)?
Current value of includePaths -"includePaths": ["src/styles/variables"] - this works for regular build. For esbuild I tried to change to [""] and ["."] but still no luck
Location of angular.json - <rootDir>/angular.json
Location of global and color scss - <rootDir>/src/styles/variables
Is the ng build command being executed from the workspace root? I was able to reproduce the problem if the current working directory was not the workspace root. There appears to be a bug regarding the includePaths not always being resolved correctly in such cases.
Hello, I had the same problem, I changed @use "src/styles/variables"; to @use "src/styles/variables.scss";
It solved the "Can't find stylesheet to import" problem.
But then it seems that some variables are no longer found :
Unfortunately, we have been unable to reproduce the issue as described. If you could provide a minimal reproduction of the issue, we can troubleshoot further.
Also, please try with the latest version of the CLI (currently 15.1.1) to see if that resolves the problem.
Unfortunately without a reproduction we are unable to look into this issue any further.
You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.
@monkeycatdog The error you provided is from a Webpack based build (@angular-devkit/build-angular:browser). This issue is about the experimental esbuild-based builder (@angular-devkit/build-angular:browser-esbuild).
Please open a separate issue if you are encountering problems with the default builder.
What it does is it allows to use short syntax: @use "globals" as *
But if I point to relative path - @use "./../styles/variables/globals" as g; es-build works. So it is definitely the problem in stylePreprocessorOptions.
Steps to Reproduce:
ng build with - browser-esbuild - observe the error
Activity
clydin commentedon Dec 27, 2022
Can you provide the current value of the
includePathsoption for the project as well as the location of theglobalandcolorsfiles relative to the workspace root (the location of theangular.jsonfile)?vmuresanu commentedon Dec 28, 2022
Current value of includePaths -
"includePaths": ["src/styles/variables"]- this works for regular build. For esbuild I tried to change to[""]and["."]but still no luckLocation of angular.json -
<rootDir>/angular.jsonLocation of global and color scss -
<rootDir>/src/styles/variablesclydin commentedon Dec 28, 2022
Is the
ng buildcommand being executed from the workspace root? I was able to reproduce the problem if the current working directory was not the workspace root. There appears to be a bug regarding theincludePathsnot always being resolved correctly in such cases.vmuresanu commentedon Dec 30, 2022
Tried it again to double check and yes - ng build is being executed from the workspace root.
gitromain commentedon Jan 12, 2023
Hello, I had the same problem, I changed
@use "src/styles/variables";to@use "src/styles/variables.scss";It solved the "Can't find stylesheet to import" problem.
But then it seems that some variables are no longer found :
X [ERROR] [plugin angular-sass] Undefined variable. ╷ 83 │ background: $color-primary-01-500; │ ^^^^^^^^^^^^^^^^^^^^^ ╵ src\app\pages\attributes-campaign\attributes-campaign-creation\attributes-campaign-creation.component.scss 83:15 root stylesheetclydin commentedon Jan 12, 2023
Unfortunately, we have been unable to reproduce the issue as described. If you could provide a minimal reproduction of the issue, we can troubleshoot further.
Also, please try with the latest version of the CLI (currently 15.1.1) to see if that resolves the problem.
monkeycatdog commentedon Jan 17, 2023
I have the same problem under my gitlab pipeline. Locally I cannot reproduce it, but under pipeline it appears sometimes. No idea what’s going on
monkeycatdog commentedon Jan 17, 2023
alan-agius4 commentedon Jan 17, 2023
Unfortunately without a reproduction we are unable to look into this issue any further.
You can read here why this is needed. A good way to make a minimal repro is to create a new app via
ng new repro-appand adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.clydin commentedon Jan 17, 2023
@monkeycatdog The error you provided is from a Webpack based build (
@angular-devkit/build-angular:browser). This issue is about the experimental esbuild-based builder (@angular-devkit/build-angular:browser-esbuild).Please open a separate issue if you are encountering problems with the default builder.
vmuresanu commentedon Jan 18, 2023
I have reproduced the issue - https://github.com/vmuresanu/Repro-App . Like I stated in original issue, the problem is in
What it does is it allows to use short syntax:
@use "globals" as *But if I point to relative path -
@use "./../styles/variables/globals" as g;es-build works. So it is definitely the problem in stylePreprocessorOptions.Steps to Reproduce:
browser-esbuild- observe the errorbrowser- the is no errorsalan-agius4 commentedon Jan 18, 2023
Thanks for the repro @vmuresanu.
What is happening here is that
globalin being resolved incorrectly as a node package even though it does not export any CSS.Code:
angular-cli/packages/angular_devkit/build_angular/src/builders/browser-esbuild/sass-plugin.ts
Lines 120 to 129 in c3adf11
angular-automatic-lock-bot commentedon Feb 19, 2023
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.