[英]Vue.js: Invalid options in vue.config.js: "plugins" is not allowed
I have a webpack project and I want to use Stylelint for SCSS linting.我有一个 webpack 项目,我想使用 Stylelint 进行 SCSS linting。 I have followed the instructions on the Stylelint website and installed:
我已按照 Stylelint 网站上的说明进行安装:
"stylelint": "^12.0.1",
"stylelint-webpack-plugin": "^1.1.2",
And then I have put this in vue.config.js:然后我把它放在 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:这是 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
}
The easiest way to tweak the webpack config is providing an object to the configureWebpack option in vue.config.js:调整 webpack 配置的最简单方法是为 vue.config.js 中的configureWebpack选项提供一个对象:
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [new MyAwesomeWebpackPlugin()]
}
}
The object will be merged into the final webpack config using webpack-merge.该对象将使用 webpack-merge 合并到最终的 webpack 配置中。
Checkout https://cli.vuejs.org/guide/webpack.html for more information.查看https://cli.vuejs.org/guide/webpack.html了解更多信息。
Have you try with this syntax :你有没有尝试过这种语法:
const StylelintPlugin = require('stylelint-webpack-plugin')
module.exports = {
assetsDir: 'asset',
configureWebpack: config => {
config.entry = '@/wrapper/main.js'
},
chainWebpack: config => {
config.plugins.delete('prefetch')
config.plugin('stylelint').use(StylelintPlugin, [
{
files: '**/*.s?(a|c)ss'
}
])
},
lintOnSave: undefined,
runtimeCompiler: true
}
That is how we managed to make it work.这就是我们设法让它发挥作用的方式。
Maybe this will help someone也许这会帮助某人
// vue.config.js
module.exports = {
configureWebpack: {
plugins: [
new MyAwesomeWebpackPlugin()
]
}
}
// In my case i was doing below and was facing the same error
const path = require('path')
const PrerenderSPAPlugin = require('prerender-spa-plugin')
module.exports = {
configureWebpack: {
plugins: [
new PrerenderSPAPlugin({
// Required - The path to the webpack-outputted app to prerender.
staticDir: path.join(__dirname, 'dist'),
// Required - Routes to render.
routes: ['/', '/page-path', '/another-page'],
})
]
},
lintOnSave: false
}
https://cli.vuejs.org/guide/webpack.html#simple-configuration https://cli.vuejs.org/guide/webpack.html#simple-configuration
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.