I have a goal to reduce the size of the bootstrap file bootstrap.min.css
. After some research, I discovered that utilizing SASS and then SCSS is an effective method to achieve this by importing only the specific components needed. Despite my previous experience with CSS, I am new to using SASS. I am currently working with the latest Bootstrap version and have downloaded the Sass [source files][1] for Bootstrap.
However, when attempting to convert the SCSS file to CSS, I encountered an error. Despite exploring solutions on stackoverflow (such as importing
@import "../scss/bootstrap/maps";
), none of them resolved the issue. The error message reads as follows:
Error: Undefined variable.
╷
21 │ @each $color, $value in $theme-colors-rgb {
│ ^^^^^^^^^^^^^^^^^
╵
scss/bootstrap/_root.scss 21:27 @import
scss/custom.scss 16:9 root stylesheet
The file path is Desktop/myproject/scss/bootstrap
. Here are the steps from my process:
Within the project, I added a "scss" folder containing another folder named "bootstrap" where all the SCSS files reside - located at
myproject/scss/bootstrap
(downloaded from the provided link).In the project directory, I created a file called custom.scss at
myproject/scss/custom.scss
3. In the custom.scss
file (which contains only these imports), I listed the names of the required components:
@import "../scss/bootstrap/functions";
@import "../scss/bootstrap/variables";
@import "../scss/bootstrap/mixins";
@import "../scss/bootstrap/root";
@import "../scss/bootstrap/reboot";
@import "../scss/bootstrap/type";
@import "../scss/bootstrap/images";
@import "../scss/bootstrap/containers";
@import "../scss/bootstrap/grid";
@import "../scss/bootstrap/offcanvas";
@import "../scss/bootstrap/navbar";
@import "../scss/bootstrap/card";
@import "../scss/bootstrap/dropdown";
@import "../scss/bootstrap/list-group";
@import "../scss/bootstrap/nav";
- To convert the
custom.scss
file intobootstrap.min-news.css
, I entered the following command in the Visual Studio terminal:sass scss/custom.scss:css/bootstrap.min-new.css
Is there a way to successfully convert the file without encountering errors? Thank you
P.S: Trying to import
also results in the following error:@import "../scss/bootstrap/maps";
Error: Undefined variable.
╷
55 │ "primary": $primary-text-emphasis-dark,
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
UPDATE
Upon importing
@import "../scss/bootstrap/variables-dark"
, the problem was resolved, and the compilation proceeded correctly. However, since I do not require variables-dark, it unnecessarily increases the file size. My aim remains to decrease the overall size of the file