问题描述
Invalid options object. PostCSS Loader has been initialized using an options object that does not match the API schema.
options has an unknown property ‘plugins’. These properties are valid:
object { postcssOptions?, execute?, sourceMap?, implementation? }
这个问题是我们在使用postcss-pxtorem运行项目的时候的报错,其实并不难,好多人就把报错放到百度上搜,怎么都解决不了,其实我们仔细读一下大概意思就是:
postcss应该是个对象,但是这个对象没有plugins,只有{ postcssOptions?, execute?, sourceMap?, implementation?}这四个属性,修改后用postcssOptions包住plugins就好了,下面是修改后的配置,其实好多报错我们认证读一下就能找到解决方法
// vue.config.js
module.exports = {
css: {
loaderOptions: {
postcss: {
postcssOptions: {
plugins: [
require("postcss-pxtorem")({ rootValue: 16, propList: ["*"] }),
],
},
},
},
},
};
希望能对你有所帮助哦