Can't configure CSS prefixing with browserslist
See original GitHub issueIs 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
- Create a new project with
react-scripts
@1.1.5 - 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
}
- Configure
browserslist
inpackage.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:
- Created 5 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Thanks for your answer 👍 at least now it’s clear I’m not lucky 😆… 😞