_custom.scss alternatives
See original GitHub issueNow that _custom.scss has been remove in https://github.com/twbs/bootstrap/pull/22821, I wonder how builds with custom colors and the likes could be made. My build so far was
- Clone
twbs/bootstrapto a temporary location - Copy my
_custom.scssinto thescssdirectory - Run npm build scripts
- Copy the compiled .css and .js files to my project
The PR mentions it was nuked “in favor of relying on imports from package manager directories” but I have a hard time following? Anyone care to explain?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:25 (2 by maintainers)
Top Results From Across the Web
What are some alternatives to Sass? - StackShare
Alternatives to Sass ... Stylus, styled-components, PostCSS, Bootstrap, and Less are the most popular alternatives and competitors to Sass. Tool Profile.
Read more >20 best alternatives to Sass as of 2022 - Slant.Co
What is the best alternative to Sass? · Angular · Inkscape · GIMP · Font Awesome · Laravel 5 · Atom · Photoshop...
Read more >How to Use PostCSS as a Configurable Alternative to Sass
This tutorial explains how to create a custom CSS preprocessor which compiles Sass syntax and supplements it with further features.
Read more >Alternative or better architecture of sass guidelines to build ...
My thinking is that it would be much better to build home.scss and contact.scss (no partials) and so on, having so two different...
Read more >Sass Alternatives (14 Similar Tools as of December, 2022)
According to people there are many software similar to it, and the best alternative to Sass is Less Other highly recommended applications ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@supergithubo
Be careful making a statement like that. It will make any previous assignment more important than the assignment using
!default, but it won’t be the same as the previous assignment being!important.I wouldn’t say “expecting”, but rather “supports”. The
!defaultkeyword really only applies to previously defined variables. Consider the 3 examples below:Example 1 is a plain example where the second declaration would override the first. Example 2 is from how Bootstrap used to support custom overrides by defining their values as defaults that only get set if no previous value was declared. Example 3 is how my setup works. Example 3 is effectively equivalent to example 1 since the
!defaultflag bears no effect on the second declaration. Therefore all 3 examples end in the same result.$varwill be#FFFwhen the SASS compiler does its thing.So, while your suggestion/point does work for overriding Bootstrap’s default values, it still has a major issue (in my opinion): Your
custom-variables.scssis a copy of_variables.scss. If you only want to override a few variables, why make a copy of ~900 lines of code just to change a few? Also, as Bootstrap evolves and they make changes, you’ll have to manually merge changes from_variables.scssto yourcustom-variables.scss. Otherwise you might be still declaring variables that are no longer used.In my previous comment I made a point about changing only the primary theme color, which using your method would result in having to copy the declarations for
$theme-colorsmap,$colorsmap, all of the individual colors variables,$graysmap, and all of the individual gray color variables. By my count that is 58 lines of variable declarations that need to be copied just to change one color value. Using my method, however, I would only have to redefine the$theme-colorsmap, or 10 lines of code.I DID, however, find a way where Bootstrap could provide its default map values and a developer could override specific keys in a file BEFORE the
_variables.scss(like supergithubo proposes):The first line in the Bootstrap file,
$theme-colors: () !default;is in case the developer does not declare (to override) the$theme-colorsmap. In that case, it provides a default, empty map to merge in the next line.The second line declares Bootstrap’s default map as the first input to map-merge which is then overridden by values in the
$theme-colorsmap variable. So in the example above, 3 lines allowed me to override theprimarykey in the map without harming the defaults for the other keys.If this change could be made to all maps in
_variables.scss, then you could import your own custom Bootstrap variables file into your project without unnecessary duplication of variables, then import the completely untouched Bootstrap source tree, then import whatever else you need.I assume bootstrap is expecting overrides BEFORE _variables.scss because
!defaultis put on every variable inside_variables.scss.The
!defaultworks like this:Marking a variable with
!defaultwill make the previous variable assignment important. It’s like a reverse of!important. In my opinion, Sass!defaultis confusing.Because of this, I setup all custom variables on BEFORE/TOP of bootstrap and setup custom styles/mixin overrides on AFTER/BOTTOM of bootstrap:
(Note:
custom-variables.scssis a copy of_variables.scss)You can also assign further custom variables on top (useful for white-labeling):