如何在vue-cli程序中使用vue-loader中的precss?

时间:2017-07-12 07:27:54

标签: node.js webpack vue.js postcss vue-cli

这是代码:

postcss: [
  require('postcss-cssnext')(), // postcss is working fine if I only write this row.
  require('precss')().process({ parser: require('postcss-scss') }) // npm got error when I add this row
]

这是错误日志:

Module build failed: Error: PostCSS syntaxes cannot be used as plugins. 
Instead, please use one of the syntax/parser/stringifier options as
outlined in your PostCSS runner documentation.

似乎每个.vue文件都出现相同的错误?...

1 个答案:

答案 0 :(得分:0)

您无法将自定义解析器作为插件传递。您的配置应如下所示:

postcss: {
  options: {
    parser: require('postcss-scss')
  },
  plugins: [
    require('postcss-cssnext')(),
    require('precss')()
  ]
}