css-loader + CSS modules pure selectors
See original GitHub issueBug report
Describe the bug
css-loader
error on build.
To Reproduce
After migrating to 9.2
and testing the CSS modules features, the below configuration started erroring.
colors.css (containing only values)
@value customGreen: #3ba150;
Component.module.css
@value customGreen from "./colors.css";
.custom {
color: customGreen;
}
I am having:
./Component.module.css (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-2-1!./node_modules/postcss-loader/src??__nextjs_postcss!./Component.module.css)
CssSyntaxError
Selector ":import("./colors.css")" is not pure (pure selectors must contain at least one local class or id)
Expected behavior
Well it did seem to work when I had
next.config.js
module.exports = withPlugins(
[
[
withCSS,
{
cssLoaderOptions: {
localIdentName: '[name]_[local]_[hash:6]',
},
cssModules: true,
},
],
],
nextConfig
);
Not sure if there’s some tweaking to do some where, not a champ on CSS modules stuff.
I’ve tried to understand this test but no luck.
System information
- Version of Next.js: 9.2
Issue Analytics
- State:
- Created 4 years ago
- Reactions:28
- Comments:25 (6 by maintainers)
Top Results From Across the Web
css-loader | webpack - JS.ORG
The loader replaces local selectors with unique identifiers. The chosen unique identifiers are exported by the module. :local(.className) { background: red ...
Read more >Targeting Pure elements in next.js with CSS modules
You will need to use a global stylesheet to target pure elements as selectors. They cannot be component-scoped. Further, you can only import...
Read more >How to configure CSS Modules for webpack - LogRocket Blog
This is achieved by creating a unique class name for CSS selectors, allowing you to use the same CSS class name in different...
Read more >Basic Features: Built-in CSS Support - Next.js
Next.js supports including CSS files as Global CSS or CSS Modules, using `styled-jsx` for CSS-in-JS, or any other CSS-in-JS solution! Learn more here....
Read more >client/node_modules/css-loader - GitLab
Then add the plugin to your webpack config. For example: file.js ... Using pure value requires selectors must contain at least one local...
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
I’ve been attempting to migrate our codebase onto Next, but just today discovered that our SCSS implementation breaks because all of our selectors have to be pure (and plenty are not). While I get why pure selectors would be ideal, it makes it impossible for large, enterprise projects full of “legacy” SCSS to migrate. I’ll never get funding for a tech debt effort to update 100+ scss files. There should be a flag to turn off pure mode.
Same here. At present we can’t migrate to this built-in feature because of this problem.