Can Angular CLI pass environment-specific settings to Sass variables?

后端 未结 3 1561
感动是毒
感动是毒 2020-12-10 04:47

When building an Angular 2 app using Angular CLI/webpack, I\'d like to specify values for a few Sass variables. Like make some url(#{$my-base-path}/...) or

3条回答
  •  萌比男神i
    2020-12-10 05:23

    No, it doesn't.

    Only the environment .ts files. No SASS.

    Here's something else you can do:

    • Use TS environment files to get some config value (save to global variable or something in main.ts - I think there used to be issues loading it in other files)
    • Have two empty components with encapsulation: ViewEncapsulation.None, so that their SASS files are global
    • *ngIf each of the 2 components based on the value you stored from environment file

    One other way is to call ng eject to get the CLI to convert the project into a normal webpack project that you can modify its config (RC0 and above).

提交回复
热议问题