Reputation: 394
I start to write my own SCSS along with boostrap
. I follow the hierarchy of the framework like:
/* The main file and all partial files are in the same directory */
@import "variables";
@import "mixins";
@import "other-components";
Everything compiles perfectly except that every variable from variables.scss
is not compiled. From my understanding, CSS doesn't have variables except for :root
, so SCSS variables will be compiled directly to its value in CSS. But when it's done compiling, the variables in CSS remain the same as they're in SCSS, just name like --primary
but not value like #000
.
Before my post gets slammed as duplicate, here's what I've done:
@use
and use as namespace instead of @import
.variables
file with and without underscore _
back and forth. It doesn't help solve the problems.sass
package to compile .scss
to .css
. No extra libraries.Any help is appreciated!
Upvotes: 3
Views: 2380
Reputation: 17358
When using standard CSS variables, you should make SASS write out the contents like this:
--variable: #{$sass-var};
Otherwise SASS will print the variable as if it's a valid value inside a CSS value (since you could technically define something like --var: $text
and then use it later with content: var(--var)
to print out that string). Anyways, it's because SASS otherwise doesn't know if you want to print the output of the variable, or just a string named similar to a sass variable.
Upvotes: 9