terence55 / themes-switch

Toolset for switch multiple themes in application based on webpack
54 stars 18 forks source link

Get rid of "default" flag for SASS #1

Closed iliatcymbal closed 6 years ago

iliatcymbal commented 6 years ago

Is it possible to set scss variables without !default directive? It looks bad and bit confusing (css or sass rules don't have "default" rule, it's some unnecessary artifact)

terence55 commented 6 years ago

When scss files were transformed to css files, variables substitutions would be the nearest variable definition before the selector, but not the last variable definition. That's different from less. So all the generated theme files would have the same content.

original scss:

$content: "First content";
.main {
  content: $content;
}
$content: "Second content";

css:

.main {
  content: "First content";
}

To solve the problem, theme-level variables will be imported before default variables and default variables should be marked with !default.

css or sass rules don't have "default" rule, it's some unnecessary artifact

Actually sass has the default rule, for more details, you can visit the sass documentation. https://sass-lang.com/documentation/file.SASS_REFERENCE.html#variable_defaults_default

iliatcymbal commented 6 years ago

Ah, ok, got it. But stiil fill uncomfartable with this !default) Thank you

terence55 commented 6 years ago

Indeed, it's different from other style formats in sass, only the variables marked with !default can be substituted by individual theme variables in compilation. I also wanna discard it if I can.