1

I have started using Angular multi-projects workspace. So I created a style folder which contains all my shared scss files.

In the angular.json file, for each project I have added the following in the architect/build/options section:

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

but when I run ng build my-project or ng serve my-project the main.scss file under styles folder is not included.

This file basically imports all the scss files that are in the subfolders under `styles´ like this

 @import "base/base";
 @import "base/typography";
 @import "base/helpers";
 @import "base/fonts"; 

enter image description here

What am I doing wrong ?

Sam
  • 13,934
  • 26
  • 108
  • 194
  • 1
    By "not included", you mean that if you do `@import 'main'`, nothing happens? That's weird. Your setup seems to be ok. – julianobrasil Nov 26 '20 at 21:47
  • duh ! I forgot to do the import in each app's style.scss file ! I dumbly thought that including the path was enough... Thanks for pointing this out. – Sam Nov 26 '20 at 22:13

1 Answers1

1

I have been facing this issue in Angular14. Earlier I had been using a relative path for importing global SCSS files (using '~' sign). But latest version of Angular stopped using this sign and also it started using DartSCSS. Till now, it seems that Angular14 has not been supporting stylePreprocessorOptions in its angular.json file. github thread has also no clue on this issue. So, as of now I have removed stylePreprocessorOptions from angular.json and added path as "@import './src/styles/global-mixins This resolves two issues-

  1. I don't need to use ~ sign anymore.
  2. No need to add a relative path like ../../../styles/global-mixins

In future, if I get some solution to this problem I will update here.

akgupta
  • 101
  • 1
  • 6
  • This is very strange. 1. stylePreprocessorOptions worked for me in Angular 14. But it stopped to work when I upgraded to Angular 16, and I can't find why. 2. I was, frankly, skeptical about your solution, as it seems not to make sense logically speaking. But… it works! So it is good enough for me. Thanks. – PhiLho Aug 01 '23 at 10:40