Vue.js: Invalid options in vue.config.js: "plugins" is not allowed

Bobby picture Bobby · Dec 31, 2019 · Viewed 9k times · Source

I have a webpack project and I want to use Stylelint for SCSS linting. I have followed the instructions on the Stylelint website and installed:

"stylelint": "^12.0.1",
"stylelint-webpack-plugin": "^1.1.2",

And then I have put this in vue.config.js:

plugins: [
  new StylelintPlugin({
    files: '**/*.s?(a|c)ss'
  })
],

And when I start the server I get this:

Invalid options in vue.config.js: "plugins" is not allowed

I have searched high and low but I have not found anything. Any help would be appreciated.

Here is the vue.config.js:

const StylelintPlugin = require('stylelint-webpack-plugin')

module.exports = {

  plugins: [
    new StylelintPlugin({
      files: '**/*.s?(a|c)ss'
    })
  ],

  assetsDir: 'asset',

  configureWebpack: config => {
    config.entry = '@/wrapper/main.js'
  },

  chainWebpack: config => {
    config.plugins.delete('prefetch')
  },

  lintOnSave: undefined,
  runtimeCompiler: true
}

Answer

ealef picture ealef · Feb 22, 2020

The easiest way to tweak the webpack config is providing an object to the configureWebpack option in vue.config.js:

// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [new MyAwesomeWebpackPlugin()]
  }
}

The object will be merged into the final webpack config using webpack-merge.

Checkout https://cli.vuejs.org/guide/webpack.html for more information.