0

StackBlitz link

For some reason when setting Bootstrap variables to a CSS3 variables my Angular 6 app breaks with the following error

enter image description here

This is indeed the first usage of the SCSS variable in the bootstrap file, so it is obviously not happy with how I am setting it. I have made a very simple StackBlitz to replicate the issue. Have a look at the styles.scss.

Essentially this is what produces this error.

styles.scss

:root{
  --primary: #0f0;
}

$primary: var(--primary); // Broken
// $primary: #f00;  // Working

@import '../bootstrap/scss/bootstrap';

Any ideas on why Bootstrap may not be happy with this?

6
  • try map-get to achieve this Commented Sep 6, 2018 at 9:48
  • 2
    it's actually css3 vars;) Commented Sep 6, 2018 at 9:49
  • Any chance you could provide an example? Will mess around a bit now. Thanks. Commented Sep 6, 2018 at 9:49
  • 1
    And what is the purpose of this? since you have a CSS variable why introducing a SCSS variable? Commented Sep 6, 2018 at 9:50
  • Trying to use angular fileReplacment to dynamically change the theme depending on the environment. And bootswatch needs these SCSS variables. See this stackoverflow.com/questions/52184282/… Commented Sep 6, 2018 at 9:56

1 Answer 1

1

Found the answer.

It appears you cannot use css variables within SASS functions due to the dynamic nature of css variables together with the fact that sass is a preprocessor.

See this stack for a more detailed explanation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.