1

I have found everything related to angular material theming, however, it's not the case.

After Angular 16 upgrade to Angular 17 I cannot import some styles from a specific node_module.

HookWebpackError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js): Can't find stylesheet to import.

Everything was working fine before the upgrade

Example import: @import '@package/src/components/specific-component';

If the scss file in node_module that I'm trying to import doesn't have any imports inside of it, everything works without any errors, however, if it has - I get provided error.

specific-component.scss (from node_module) - that would give an error, if I tried importing it in my own scss

@import 'mixins';

.specific-class {
  @include something();
}

specific-component.scss - that works and imports normally as before.

//@import 'mixins';

.specific-class {
  color: white;
}

Anyone encountered something similar and resolved that?

2
  • what is the angular exact version? Commented Oct 29, 2024 at 9:14
  • Angular 17.3.10
    – mimasik
    Commented Oct 29, 2024 at 9:16

2 Answers 2

1

Please try below configuration in your angular.json file (path: projects..architect.build.options.stylePreprocessorOptions)

Configuration:

"stylePreprocessorOptions": { "includePaths": [ "." ] }

0
0

Make sure you have added the paths of the scss files you want to use in the stylePreprocessorOptions, includePaths inside angular.json.

"stylePreprocessorOptions": {
   "includePaths": [
     "src/styles",
     "src/assests/styles"
  ]
}

Then try importing them like.

@import 'mixins.scss';

.specific-class {
  @include something();
}
6
  • perhaps this is the correct solution if styles are local, but I'm taking these styles from node_module, ``` "includePaths": [ "node_modules" ] ``` I have already added it in stylePreprocessorOptions, however, with no luck :/
    – mimasik
    Commented Oct 29, 2024 at 10:31
  • the example files I provided are the example .scss files in the specific node_module that I'm taking from
    – mimasik
    Commented Oct 29, 2024 at 10:32
  • @mimasik If you want to do like that, you have to also add the mixin path that example.scssuses, which is also located in the node_,modules folder Commented Oct 29, 2024 at 10:36
  • Isn't there a way to add everything from that node package? Because that mixin is importing other files (like variables, etc.), so if I would use multiple styles scss files that "includePaths" could get quite huge.
    – mimasik
    Commented Oct 29, 2024 at 11:03
  • stackoverflow.com/questions/69218193/… I found some similar issue, however, the solution doesn't work for me in angular 17
    – mimasik
    Commented Oct 29, 2024 at 11:12

Not the answer you're looking for? Browse other questions tagged or ask your own question.