Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post CSS processing is breaking variables on css when building app #11685

Open
andres-upshow opened this issue Nov 26, 2021 · 10 comments
Open

Post CSS processing is breaking variables on css when building app #11685

andres-upshow opened this issue Nov 26, 2021 · 10 comments

Comments

@andres-upshow
Copy link

Describe 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

  1. npx create-react-app
  2. edit index.css add something like a background-color: var(--white);
  3. build

Expected behavior

Style background-color to be var(--white)

image

Actual behavior

Style background-color is changed to be var(#fff)

image

Reproducible demo

@ivanafanasyeu
Copy link

ivanafanasyeu commented Nov 26, 2021

Have same issue. In dev mode it works correctly, but after build variables goes wrong, like was described

@andres-upshow
Copy link
Author

After trying to fix it by asking on postcss to no avail (they are kind of angry at you) I ejected the application and removed this portion of config/webpack.config.js which fixed the issue
image

This is of course not ideal but I hope will shed some light on how to implement a proper fix

@andres-upshow
Copy link
Author

Now I'm confused
Going over the code of optimize-css-assets-webpack-plugin found no usage of the parser option, so it is defaulting to use cssnano
Now, cssnanno also has some changes on the last two days, so I will try to check what was changed over there.

@andres-upshow
Copy link
Author

Could be related to this update on cssnano cssnano/cssnano#1207

@andres-upshow
Copy link
Author

Confirmed on eject, if I disable colormin the issue goes away.

          cssProcessorPluginOptions: {
            preset: ['default', { minifyFontValues: { removeQuotes: false, colormin: false } }],
          },

@vinayakfz
Copy link

vinayakfz commented Nov 27, 2021

I think you should have colormin argument outside the object of minifyFontValues.
This way you are sending arguments to minifyFontValues instead of disabling colormin's configuration.

BTW, This whole issue is a life-saver for me, suddenly our website blew up in staging environment. 😁

@andres-upshow
Copy link
Author

I think you should have colormin argument outside the object of minifyFontValues.
You are right, my bad

@XxStunner
Copy link

XxStunner commented Nov 27, 2021

@andres-upshow Thanks bro, I was able to fix the same issue in a nuxt.js project (lol) by editing the cssnano config.

@andres-upshow
Copy link
Author

andres-upshow commented Nov 28, 2021

I was able to track the bug to some bugfix on color-string https://github.com/Qix-/color-string/issues/60
Specially this fix: Qix-/color-string@09cba37

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 disabling colormin 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.

@stale
Copy link

stale bot commented Jan 8, 2022

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants