项目场景:
尝试ant design vue pro ,安装好项目run serve报错
问题描述
yarn run v1.22.18
$ vue-cli-service serve
ERROR Error loading vue.config.js:
ERROR ValidationError: Invalid options object. Ignore Plugin has been initialized using an options object that does not match the API schema.
- options should be one of these:
object { resourceRegExp, contextRegExp? } | object { checkResource }
原因分析:
定位到
vue.config.js
中的问题位置 webpack.IgnorePlugin
plugins: [
// Ignore all locale files of moment.js
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin({
APP_VERSION: `"${require('./package.json').version}"`,
GIT_HASH: JSON.stringify(getGitHash()),
BUILD_DATE: buildDate
})
]
解决方案:
看看帮助文档,然后惯例ctrl+c,ctrl+vwebpack.IgnorePluginhttps://webpack.docschina.org/plugins/ignore-plugin/
plugins: [ // Ignore all locale files of moment.js // new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), new webpack.IgnorePlugin({ resourceRegExp: /^\.\/locale$/, contextRegExp: /moment$/ }), new webpack.DefinePlugin({ APP_VERSION: `"${require('./package.json').version}"`, GIT_HASH: JSON.stringify(getGitHash()), BUILD_DATE: buildDate }) ],