Angular: Use SASS @import regardless of its actual location
08/02/2021 by admin

Imagine this scenario: You have a _variables.scss file with all the variables ready to use but you don't want to have to copy those files to every module that needs them.

Rather you would like to be able to do a simple @import "variables";  in the sass file of your component no? well read on :)

To achieve this functionality we are going to edit the angular.json file located in the root of your project. Look for the key "stylePreprocessorOptions" and define (or add) inside it the following:

"stylePreprocessorOptions": {
  "includePaths": [

What we've done here is to tell aungular to expose those directories ("src/styles/utils" and "src/styles/business-utils") wherever a SASS file is compiled, allowing us to @include any files found there in our components.

It's that easy.


Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.