Skip to content

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

Closed

Description

@solonaarmstrong-zz

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.

Activity

  1. jonathantneal commented on Nov 5, 2018

    @jonathantneal

    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.

  2. locked and limited conversation to collaborators on Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions