1

There is create-react-app (react 17), eject is executed to access the configs, there is the scss module index.module.scss and it uses the $white variable from the colors.scss file with colors. The module is isolated and there is no access to the variable. The only solution I found was to turn colors.scss into a module and import it into every scss file that uses color value variables. Is there a way to make these scss variables available to all files without doing this copying?

//colors.module.scss
$ white: #ffffff;


// index.module.scss
@import "~ scss/colors.module";

.wrapper {
   background-color: $white;
}

I found an old solution here, this is one to one my situation, only in React, but I could not write it in the config so that it worked (if I understood correctly, in ./config/webpack.config.js), maybe someone can help with this

Using SCSS variables in CSS Modules

0

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.