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

Bug: Using opacity as a percentage value in a css file will become 1% in the production build. #19747

Closed
mruiz42 opened this issue Sep 2, 2020 · 7 comments
Assignees
Labels
Resolution: Needs More Information Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug

Comments

@mruiz42
Copy link

mruiz42 commented Sep 2, 2020

Using opacity as a percentage value in a css file will become 1% in the production build version, even though in the localhost website it will appear correctly. The way around this is to use a decimal value (ex. 0.95) for opacity.

React version: 16.13.1

Steps To Reproduce

  1. Set a css class to have a percentage opacity value (ex. 95%)
  2. run npm run-scrips build
  3. build version will have incorrect percentage (1%)

code example:

.App {
font-family: sans-serif;
text-align: center;
opacity: 50%;
}

The current behavior

Opacity will change from any percentage value to 1% in app build version.

The expected behavior

Opacity will stay the same percentage in build version.

@mruiz42 mruiz42 added the Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug label Sep 2, 2020
@gaearon
Copy link
Collaborator

gaearon commented Sep 2, 2020

A reproducing example, please.

@bvaughn
Copy link
Contributor

bvaughn commented Sep 2, 2020

It doesn't look like this bug report has enough info for one of us to reproduce it.

Please provide a CodeSandbox (https://codesandbox.io/s/new), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. Screenshots or videos can also be helpful if they help provide context on how to repro the bug.

Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve

@mruiz42
Copy link
Author

mruiz42 commented Sep 2, 2020

Here is the code sandbox, as requested.
https://codesandbox.io/s/trusting-glitter-0icl7
Deployed sandbox: (Where the issue arises, when built.)
https://csb-0icl7.netlify.app/

@bvaughn
Copy link
Contributor

bvaughn commented Sep 2, 2020

Did you forget to commit CSS to the source sandbox you linked?

What I see is:

.App {
  font-family: sans-serif;
  text-align: center;
}

@mruiz42
Copy link
Author

mruiz42 commented Sep 2, 2020

Did you forget to commit CSS to the source sandbox you linked?

What I see is:

.App {
  font-family: sans-serif;
  text-align: center;
}

I guess I forgot to press ctrl+s to save the changes. Should be up now.

@eps1lon
Copy link
Collaborator

eps1lon commented Sep 3, 2020

What a frustrating bug. It originates in react-scripts (reported in facebook/create-react-app#7980). It seems like the underlying fix wasn't propagated. If you go further down you find NMFR/optimize-css-assets-webpack-plugin#118 and cssnano/cssnano#881.

I'd suggest tracking down which package didn't publish the fix by upgrading their relevant dependencies.

Maybe @gaearon can move this issue to create-react-app. Otherwise we should file a new bug report with create-react-app and close it here.

@bvaughn
Copy link
Contributor

bvaughn commented Sep 3, 2020

Thanks for the investigation and summary, @eps1lon!

Migrated to facebook/create-react-app#9588

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Needs More Information Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug
Projects
None yet
Development

No branches or pull requests

4 participants