Skip to content

CSS variables with fallback values used in linear-gradient throws error in build process #5426

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

Closed
solonaarmstrong-zz opened this issue Oct 12, 2018 · 1 comment · Fixed by #5721

Comments

@solonaarmstrong-zz
Copy link

solonaarmstrong-zz commented Oct 12, 2018

Is this a bug report?

Yes, bug report.

Did you try recovering your dependencies?

Yes.

Which terms did you search for in User Guide?

This issue is similar, but outdated.

Environment

Environment:
OS: macOS High Sierra 10.13.6
Node: 10.8.0
Yarn: 1.9.4
npm: 6.2.0
Watchman: 4.9.0
Xcode: Xcode 10.0 Build version 10A255
Android Studio: 3.0 AI-171.4408382

Packages: (wanted => installed)
react: ^16.5.2 => 16.5.2
react-dom: ^16.5.2 => 16.5.2
react-scripts: 2.0.4 => 2.0.4

Steps to Reproduce

  1. npx create-react-app css-bug && cd css-bug
  2. Add something like this to App.css
.App-header {
  --progress-lower: #ffcc00;
  --progress-upper: #3333cc;
  --App-header-progress: 25%;
  
  background-image: linear-gradient(
      to right,
      var(--progress-lower, transparent) 0%,
      var(--progress-lower, transparent) var(--App-header-progress, 0%),
      var(--progress-upper, transparent) var(--App-header-progress, 100%),
      var(--progress-upper, transparent) 100%
    );
  1. The multiple fallback (default) values in the variables are the culprit.
  2. yarn start

More details in this issue.

Expected Behavior

I expected to use multiple CSS variables with fallbacks without build errors.

Actual Behavior

It throws an error Unclosed bracket

./src/App.css (./node_modules/css-loader??ref--6-oneOf-3-1!./node_modules/postcss-loader/src??postcss!./src/App.css)
Unclosed bracket (17:36)

  15 | 
  16 |   /* background-color: #282c34; */
> 17 |   background-image: linear-gradient(
     |                                    ^
  18 |       to right,
  19 |       var(--progress-lower) 0%,
  20 |       var(--progress-lower) 0%,

screen shot 2018-10-12 at 1 23 38 pm

Reproducible Demo

This demo works in the sandbox and the issue seems to lie with postcss-custom-properties, but I'm posting this issue as reference for others who may run into the same problem.

@jonathantneal
Copy link

This was a bug in PostCSS Custom Properties which was fixed and published in a new patch release. That should be enough to resolve it.

PostCSS Custom Properties is used by PostCSS Preset Env, which has taken in the change and published it in a new patch version.

@lock lock bot locked and limited conversation to collaborators Jan 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants