0

I use a lot variables in scss. so i create file which contain all scss-variables. Now i need import this file to another scss-files.

My try:

  1. create file scss-vars.scss in root catalog
  2. write in tsconfig.json:
"@bla/blaa/a/scss-vars":["libs/ui/scss-vars.scss"],
  1. in all scss-files use follow import:
@import "@bla/blaa/a/scss-vars.scss";

But in result i get follow error message in console:

Can't find stylesheet to import.

I need import scss file without absolute path use.

Evaldas Buinauskas
  • 13,739
  • 11
  • 55
  • 107
sergK
  • 13
  • 3
  • Generally doing it [this way](https://scotch.io/tutorials/angular-shortcut-to-importing-styles-files-in-components#toc-shortcut-with-angular-cli-configuration) makes life much easier. – Chris W. Aug 28 '19 at 19:42
  • @Patrik Alexits but it approachs are not work for scss. They are work only for sass – sergK Aug 28 '19 at 20:35

2 Answers2

1

You can create an alias for your folders in the angular.json file.

Just search for 'styles.scss' and you will find where to add any other path you'd like.

        "styles": [
          "src/styles.scss",
          "src/my-folder/some-styles.scss", // now you can import some-styles globally
        ],

in some random-file.scss

@import 'some-styles';

0

CSS preprocessors do not look at tsconfig.json paths. There is an open issue on the Angular CLI repo regarding this topic.

Sam Herrmann
  • 6,293
  • 4
  • 31
  • 50