Post CSS processing is breaking variables on css when building app
See original GitHub issueDescribe the bug
There is some post css script changing variables like --white
to #fff
Did you try recovering your dependencies?
Started from scratch
Which terms did you search for in User Guide?
css
, and I saw the section for post processing, but if this is intended please say so because it was working fine about 2 days ago
Environment
Environment Info:
current version of create-react-app: 4.0.3
running from /Users/amephist/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app
System:
OS: macOS 12.0.1
CPU: (8) x64 Apple M1
Binaries:
Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node
Yarn: Not Found
npm: 8.1.3 - ~/.nvm/versions/node/v14.18.1/bin/npm
Browsers:
Chrome: 96.0.4664.55
Edge: Not Found
Firefox: Not Found
Safari: 15.1
npmPackages:
react: ^17.0.2 => 17.0.2
react-dom: ^17.0.2 => 17.0.2
react-scripts: 4.0.3 => 4.0.3
npmGlobalPackages:
create-react-app: Not Found
Steps to reproduce
- npx create-react-app
- edit index.css add something like a
background-color: var(--white);
- build
Expected behavior
Style background-color to be var(--white)
Actual behavior
Style background-color is changed to be var(#fff)
Reproducible demo
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:10
Top Results From Across the Web
What is PostCSS? How to Use Plugins to Automate CSS Tasks
PostCSS is a JavaScript tool that transforms your CSS code into an abstract syntax tree (AST) and then provides an API (application ......
Read more >Deconfusing Pre- and Post-processing | by Stefan Baumgartner
If you take it seriously, the use of CSS variables — even with it being backed by the spec — is pre-processing. None...
Read more >CSS Modules Breaking in Production with Create React App
After running create-react-app's standard npm run build the produced main.css file would replace my css like this: Some CSS Module Before ...
Read more >Why We're Breaking Up with CSS-in-JS - DEV Community
CSS -in-JS clutters the React DevTools. Static extracted styles will replace your styles with classNames and/or CSS variables. No clutter (not ...
Read more >PostCSS API
Create a new Processor instance that will apply plugins as CSS processors. let postcss = require('postcss') postcss(plugins).process(css, { from, ...
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 was able to track the bug to some bugfix on color-string https://github.com/Qix-/color-string/issues/60 Specially this fix: https://github.com/Qix-/color-string/commit/09cba3771759a16ba3bf25ef1c7374cd1d4f2e10
Now, if you have a way to lock versions (we have it due to rush/pnpm) lock package
color-string
to version 1.7.0 and everything should go back to normal while you wait for a formal resolution. If you ejected CRA then disablingcolormin
cssnano’s default plugin also works.This whole ordeal is the thing that pops on my mind when someone complaints about the broken ecosystem that is node modules, a bugfix on a library without proper semantic versioning causes a hot potato situation that wastes everybody’s time.
Have same issue. In dev mode it works correctly, but after build variables goes wrong, like was described