autoprefixer 插件不生效

506 阅读1分钟

1、安装好autoprefixer插件后,在postcss.config.js文件中引入插件

const autoprefixer = require('autoprefixer');
const pxtorem = require('postcss-pxtorem');

module.exports = {
  plugins: [
    autoprefixer(),
    pxtorem({
      rootValue({ file }) {
        return file.indexOf('vant') !== -1 ? 37.5 : 75;
      },
      propList: ['*'],
      selectorBlackList: [],
      unitPrecision: 5,
    }),
  ],
};

2、运行项目发现没有自动加上自动加上浏览器前缀

image.png

3、在package.json文件中加入这个属性

image.png

4、重新运行项目,样式生效了

image.png