Welcome to OStack Knowledge Sharing 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 Answer

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'] })
]}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...