mimasik
mimasik

Reputation: 43

"Can't find stylesheet to import" error after upgrading to Angular 17.3.10

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

After upgrading Angular 16 to Angular 17 (17.3.10) 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?

Upvotes: 1

Views: 659

Answers (2)

Sharath Kumar
Sharath Kumar

Reputation: 26

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

Configuration:

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

Upvotes: 1

Naren Murali
Naren Murali

Reputation: 57986

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();
}

Upvotes: 0

Related Questions