-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Description
Command
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
I am thinking this is a Webpack or angular.json thing possibly. Found a lot of questions on this without a true answer. Besides to @import the mixin directly in the component and the used @import variables in the mixin file, which just seems silly to me and not ideal. I get that components are encapsulated, but you can access global styles... why not scss mixins? So, how do you get global mixins and access them in a component - without importing them directly into the component's scss file?
I created a _mixins.scss file under the theme folder. Also, in the folder I imported the mixin file in the custom.scss file. Then in the main styles.scss the custom.scss gets imported. Then inside of an angular component I use the @include to pull in the mixin, but get an error. I also have in the angular.json file the styles file marked there so it should be globally available.
I've also tried switching to @use and @import the mixin directly into the styles.scss = no dice.
My Stackoverflow question: https://stackoverflow.com/questions/76068047/why-is-my-custom-angular-scss-import-failing
Similar stackoverflow question with link to example: Angular not importing mixin
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Undefined mixin.
╷
7 │ @include card-hover-effect();
Mixin code:
@mixin card-hover-effect() {
transition: all 0.3s;
&:hover {
cursor: pointer;
transform: scale(1.02);
box-shadow: $card-box-shadow;
}
}
Minimal Reproduction
- Create an Angular Project
- Create a _mixin.scss file
- Import the mixin file in the globally used styles.scss file
- Make a component and in the component's scss file use the @include 'name of mixin';
- Make sure that the angular.json includes
"styles": ["src/styles.scss"],
"stylePreprocessorOptions": {
"includePaths": [
"location of "
]
},
Exception or Error
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: Undefined mixin.
╷
7 │ @include card-hover-effect();
Your Environment
Angular CLI: 15.2.4
Node: 16.1.0
Package Manager: npm 7.11.2
OS: darwin x64
Angular: 15.2.4
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1502.4
@angular-devkit/build-angular 15.2.4
@angular-devkit/core 15.2.4
@angular-devkit/schematics 15.2.4
@schematics/angular 15.2.4
rxjs 7.8.0
typescript 4.9.5
Anything else relevant?
No response