Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

请问vuecli3.0的配置中autoprefixer该如何配置

下面是我配置的css中,但是autoprefixer没有起效,

css: {
    sourceMap: true,
    loaderOptions: {
            sass: {
                prependData: `@import "@/styles/variables.scss";`
      },
      postcss: {
        plugins: [
          require('autoprefixer')({})
        ]
      }
        }
  },
package.json中安装了`postcss-loader`和`autoprefixer"请问我还应该怎么配置才可以使它生效。

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

如果是用vue-cli3创建的项目的话,默认是开启了这个设置的。
image.png


如果只是普通的webpack配置autoprefixer的话,直接安装这俩

npm install postcss autoprefixer
var autoprefixer = require('autoprefixer');
module.exports = {
    module: {
      loaders: [
        { test: /.css$/, loader: "style!css!postcss" },
        { test: /.scss$/, loader: "style!css!postcss!sass" }
      ]
    },
    postcss: [ autoprefixer({ browsers: ['last 2 versions'] })
]}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...