简体   繁体   中英

How can I use precss in vue-loader at a vue-cli programme?

Here is code:

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
]

Here is error log:

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.

It seems every .vue file got same error?...

You cannot pass a custom parser in as a plugin. Your config should look like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM