question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't configure CSS prefixing with browserslist

See original GitHub issue

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

CSS, autoprefixer

Environment

  System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-4712HQ CPU @ 2.30GHz
  Binaries:
    Yarn: 1.12.3 - C:\Program Files\nodejs\yarn.CMD
    npm: 6.2.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 42.17134.1.0
    Internet Explorer: 11.0.17134.1
  npmPackages:
    react: ^16.7.0 => 16.7.0
    react-dom: ^16.7.0 => 16.7.0
    react-scripts: 1.x => 1.1.5
  npmGlobalPackages:
    create-react-app: Not Found

Steps to Reproduce

  1. Create a new project with react-scripts@1.1.5
  2. Include the following in App.css
.aClass {
  position: relative;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.anotherClass {
  -webkit-box-flex: 1;
  -webkit-flex: 1 0 auto;
  flex: 1 0 auto;
  display: -webkit-inline-box;
  display: -webkit-inline-flex;
  display: inline-flex
}
  1. Configure browserslist in package.json, according to https://facebook.github.io/create-react-app/docs/post-processing-css

You can customize your target support browsers by adjusting the browserslist key in package.json according to the Browserslist specification.

My configuration is:

  "browserslist": [
    "Chrome >= 17"
  ],

I tried adding the same configuration also as .browserslistrc file.

Expected Behavior

I expect CSS bundle to include

.aClass {
  position: relative;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-orient: vertical;
  -webkit-box-direction: normal;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.anotherClass {
  -webkit-box-flex: 1;
  -webkit-flex: 1 0 auto;
  flex: 1 0 auto;
  display: -webkit-inline-box;
  display: -webkit-inline-flex;
  display: inline-flex
}

(since this is the result I get from https://autoprefixer.github.io/ with filter Chrome >= 17 and the given CSS)

Actual Behavior

Bundle only includes the following for my two classes (notice -webkit- prefixed styles are missing):

.aClass {
    position: relative;
    display: -ms-flexbox;
    display: flex;
    -ms-flex-direction: column;
    flex-direction: column
}

.anotherClass {
    -ms-flex: 1 0 auto;
    flex: 1 0 auto;
    display: -ms-inline-flexbox;
    display: inline-flex
}

Reproducible Demo

https://github.com/PiDayDev/cra-css

Clone the repo., execute npm install and then npm run build Check CSS file generated in build folder.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mrmckebcommented, Jan 31, 2019

Ah, I understand @PiDayDev - sorry I misread.

I think you’ll need to move to 2.x, or customise the config yourself I’m sorry… Let me know if we can be of any more help.

0reactions
PiDayDevcommented, Jan 31, 2019

Thanks for your answer 👍 at least now it’s clear I’m not lucky 😆… 😞

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to use browserslist with autoprefixer from NPM
The css file do get prefixed, but it autoprefixer doesn't use the browser list. Neither from the -b nor the "browserslist" .
Read more >
How to Add CSS Vendor Prefixes Automatically - Medium
CSS vendor prefixes allow the makers of web browsers to add support for the latest CSS features, for experimentation or a testing period....
Read more >
Autoprefixer 7.0 and Browserslist 2.0 - Evil Martians
With Autoprefixer, you can specify which browser versions you wish to target in your application; Autoprefixer will only add the CSS prefixes ......
Read more >
GettingStartedwithGulpSecondE...
PostCSS plugin to parse CSS and add vendor prefixes to CSS rules using values from Can I Use. It is recommended by Google...
Read more >
4.16.5 - browserslist - npm
The config to share target browsers and Node.js versions between different front-end tools. It is used in: Autoprefixer · Babel · postcss-preset ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found