I'm using autoprefix in Angular 7 Project. But When I open the browser devtools and focus the element with class "simple-content", which has display flex as applied style, there is no expected 'prefixes'. In Angular 4-6 projects, this works ok.
Step 1: Run ng serve Step 2: Open the browser devtools and focus the element with class "simple-content", which has display:flex.
In package.json I have
{
"browserslist": [
"last 1 version",
"> 1%"
]
}.
In package-lock.json I have
"autoprefixer": {
"version": "9.4.4",
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-9.4.4.tgz",
"integrity": "sha512-7tpjBadJyHKf+gOJEmKhZIksWxdZCSrnKbbTJNsw+/zX9+f//DLELRQPWjjjVoDbbWlCuNRkN7RfmZwDVgWMLw==",
"requires": {
"browserslist": "^4.3.7",
"caniuse-lite": "^1.0.30000926",
"normalize-range": "^0.1.2",
"num2fraction": "^1.2.2",
"postcss": "^7.0.7",
"postcss-value-parser": "^3.3.1"
},
I tried to enable autoprefixing for flexbox with /* autoprefixer: on */, but no result.
In css file i have
.simple-content {
display: flex;
}
Expected result :
.simple-content {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
PostCSS was developed by Andrey Sitnik, the creator of Autoprefixer. It is a Node. js package developed as a tool to transform all of your CSS using JavaScript, thereby achieving much faster build times than other processors.
PostCSS plugin to parse CSS and add vendor prefixes to CSS rules using values from Can I Use. It is recommended by Google and used in Twitter and Alibaba. Write your CSS rules without vendor prefixes (in fact, forget about them entirely): ::placeholder { color: gray; } .
Autoprefixer can be easily integrated with Sass and Stylus, since it runs after CSS is already compiled. Autoprefixer is based on Rework, a framework for writing your own CSS postproccesors. Rework parses CSS to useful JavaScript structure and exports it back to CSS after your manipulations.
I tried online autoprefixer tool (https://autoprefixer.github.io/) to test the browserlist you used in package.json and observed that it did not generate prefixed css:
On changing the browser list value to last 2 version, it generated autoprefixed css:
So your package.json seems fine and you can try it by just updating browser list.
Also FYI, angular cli V7.3.5 added src/browserslist which means you need not to add .browserslistrc or browserslist property to the package.json for angular 7 projects. All you need to do is remove not on last line to support IE 9-11.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With