I have to support IE 11 in an Angular project where we use the latest version of it. I really like to use CSS grid features that IE 11 is capable of. But I can't figure out how to get Autoprefixer work properly.
My problem is quite the same as in another question, but that deals with another version.
I created a minimal test case on Stackblitz.
I configured the browserslist file like so:
> 1%
IE 11
And I included a control comment to enable grid feature of Autoprefixer:
/* autoprefixer grid: on */
(I have done that in both CSS files, the global styles and the component styles)
My expectation with this configuration of browserslist and the control comment in the CSS file is, that Autoprefixer adds display: -ms-grid;
to the CSS output. But it doesn't.
On your command prompt, write following command to install Gulp auto-prefixer locally into your directory. npm install --save-dev gulp-autoprefixer To test this auto-prefixer, we’re going to make CSS file on the same directory with property that needs vendor prefixes like below. Go back to your gulpfile.js, copy and paste the code snippet below.
Autoprefixer is a PostCSS plugin which parses your CSS and adds vendor prefixes Autoprefixer CSS online Autoprefixer is a PostCSS plugin which parses your CSS and adds vendor prefixes Loading... Browserslist include comment with configuration to the result Select result
Autoprefixer can be used to translate modern CSS Grid syntax into IE 10 and IE 11 syntax, but this polyfill will not work in 100% of cases. This is why it is disabled by default. First, you need to enable Grid prefixes by using either the grid: "autoplace" option or the /* autoprefixer grid:...
Add grid: 'autoplace' to the options to turn grid prefixing on: Update: In version 9.4.0 limited autoplacement support was introduced to Autoprefixer. For backwards compatibility reasons, the new recommended setting for enabling grid translations is now grid: 'autoplace'. I have updated all the code snippets to reflect this new recommendation.
I don't know how its config should be in angular CLI. But in Webpack loader it configure like this:
// postcss.config.js
module.exports = {
plugins: {
'postcss-preset-env': {
autoprefixer: {
grid: 'autoplace'
},
browsers: [
'IE >= 11',
'> 0.1%'
]
}
}
};
It is too important to set grid: 'autoplace', not grid: 'on'. In Angular project in package.json you can add AUTOPREFIXER_GRID=autoplace. It will be something like this:
"build": "AUTOPREFIXER_GRID=autoplace ng build",
We recently used grids in one of our project and we also support IE11. And hopefully autoprefixer saved us. So be sure, it will definitely work if you configure it properly.
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