ValidationError: 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? }
webpack打包时遇到这个错误是因为postcss-loader目前已经更新到5.2版本了,有的同学可能是看的教程学的webpack,而教程里用的是老版本的postcss-loader.注意新老版本的API是不一样的
解决方案:把webpack.config.js的配置改成如下即可(无需降级):
{
test: /\.css$/,
use:[
MiniCssExtractPlugin.loader,//此句话也可用Style.loader代替