postcss-preset-env not being run on css modules during build
See original GitHub issueBug report
Describe the bug
When I develop locally the css vars in my css modules (eg: background: var(--white);
) get converted by postcss-preset-env
to the actual values stored in a vars.css
file which look like this:
:root {
--white: #F4F4F4;
/* ...etc */
}
This also gets applied to a global stylesheet.
However, when I run next build
, it seems like postcss-preset-env
doesn’t recognise these variables and generates css that includes background: var(--white);
with no fallback. The CSS in my global stylesheet does get converted.
I have a PostCSS config that looks like this:
module.exports = {
plugins: {
'postcss-flexbugs-fixes': {},
'postcss-import': {},
'postcss-mixins': {},
'postcss-calc': {},
'postcss-nested': {},
'postcss-color-mod-function': {
importFrom: [
'./assets/styles/vars.css',
],
},
'postcss-preset-env': {
stage: 1,
},
},
}
and I’m not using next-css
.
Expected behavior
postcss-preset-env
should convert the CSS variables in my CSS modules when running next build
.
System information
- OS: MacOS
- Version of Next.js: 9.2.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
postcss-preset-env not being run on css modules during build
However, when I run next build , it seems like postcss-preset-env doesn't recognise these variables and generates css that includes background: ...
Read more >Loading PostCSS "postcss-preset-env" plugin failed: Cannot ...
As it appears this error will temporarily get fixed by installing the latest version of Node.js . So to fix this follow these...
Read more >postcss-preset-env - npm
Start using postcss-preset-env in your project by running `npm i ... PostCSS to build your CSS, you can simply add PostCSS Preset Env...
Read more >postcss/postcss - Gitter
I am having issues getting postcss-preset-env to do anything at all. Executing it with the PostCSS-CLI, which runs other plugins successfully... My postcss....
Read more >css-loader | webpack - JS.ORG
And run webpack via your preferred method. If, for one reason or another, you need to extract CSS as a file (i.e. do...
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 FreeTop 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
Top GitHub Comments
I fixed it by modifying the config of
postcss-present-env
to include animportFrom
setting that loaded the definition of the CSS vars:This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.