Lately, I made the switch to using modules in my next.js project. However, I keep encountering an error in my newly created .module.scss files that says: "Selector ":root" is not pure (pure selectors must contain at least one local class or id)". It seems that the issue lies with the imports I am utilizing, particularly for variables like $cl-light-gray
as shown below in this sample file:
@import "src/common/styles/global-styles.scss";
@import "node_modules/bootstrap/scss/bootstrap";
@import "src/common/styles/palette.scss";
@import "src/common/styles/typography.scss";
.dashboard-dropdown-hover {
@extend .px-1;
@extend .py-2;
@extend .mt-3;
border: 1px solid transparent;
border-radius: 8px;
transition: 200ms;
background-color: transparent;
}
.dashboard-dropdown-hover:hover {
background-color: $cl-light-gray;
}
If anyone knows a solution to resolving this import issue, I would greatly appreciate any guidance. While I understand reverting to .scss may solve the problem, I'm hesitant about importing all those .scss files in _app.tsx as it would entail around 30 imports and these styles are not meant to be global. Also, I am puzzled why Next.js insists on using pure css selectors when Sass, known for its non-pure elements, is being utilized.