Search code examples
angulartypescriptsassangular2-componentscss-variables

How to import variables from typescript to sass? (Angular2 application)


I am writing application (Angular2 framework). And now I want to make different variables in sass files at development and production.

For example I want to use this solution:

@if $prod == true {
  $background-color: #fff;
} @else {
  $background-color: #333;
}

And i have $prod variable in my typescript file. But how i can pass it from typescript file to sass file?


Solution

  • Your options are:

    1. Parse the scss file in the backend
    2. Apply the style in javascript rather than the other way around