Add browser compatibility to CSS3 styles using Postcss-loader and autoprefixer in Webpack3

Source: Internet
Author: User
Tags install node postcss

1. The following two loader must be installed in the Webpack to handle CSS

NPM Install--save-dev Css-loader style-loader

2. To process sass and add browser prefixes, you need to download the following plugins and loader

Sass-loader depends on Node-sass, so install Node-sass
Postcss-loader autoprefixer postcss handles browser compatibility
NPM Install--save-dev sass-loader node-sass postcss-loader autoprefixer postcss

The configuration in 3.webpack is as follows

This is an example provided by the official website can be used completely, do not have to create a separate configuration file

Click to enter the official website address

{     /\.scss$/,     /node_modules/, use     : [            ' Style-loader ',           ' Css-loader ', options: {Importloaders:2}},  //2 a few loader           ' Postcss-loader ' on behalf of Css-loader Options:{plugins:[require ("Autoprefixer") ("Last Versions")]}}           ,' Sass-loader '          } 

4. After packing, the effect is as follows

You will never have to consider the browser compatibility issue again.

Add browser compatibility to CSS3 styles using Postcss-loader and autoprefixer in Webpack3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.