webpack2.0配置postcss-loader


使用webpack2.0配置postcssloader

安装postcss-loader

npm install --save-dev postcss-loader

然后配置webpack.config.js

{
  test:/\.css$/,
  use:[
    'style-loader','css-loader?importLoaders=1','postcss-loader' 
]
}

一种办法是配置postcss.config.js

module.exports = {
    plugins: [
        require('autoprefixer')({ /* ...options */ })
    ]
}

第二张办法是webpack.config.js使用LoaderOptionsPlugin

module.exports = {
    plugins: [
        new webpack.LoaderOptionsPlugin({
            options: {
                postcss: function(){
                    return [
                        require("autoprefixer")({
                            browsers: ['ie>=8','>1% in CN']
                        })
                    ]
                }
            }
        })
    ]
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM