Unibit
Unibit

Reputation: 99

How to override sass variables in a shared library with application specific values

Given a Nx monorepo (angular-cli) with the following layout

apps
-app1
-app2
libs
-shared
-feature1
-feature2

In the shared library resides a variables.scss file with variables for colors. The component stylesheets in the feature libraries import these variables. So far so good. Both app1 and app2 import the feature libs (lazy loaded)

Question: How can I override the color variables in order to render the feature components with different color for app1 and app2?

Upvotes: 3

Views: 916

Answers (1)

Lexi Reicks
Lexi Reicks

Reputation: 33

My solution is including the styles.scss in the styles array of the app and then in the styles.scss file I'm importing the shared variables file. Adding variables after importing the file will override the shared variables.

Upvotes: 0

Related Questions