gpt4 book ai didi

javascript - 如何防止 webpack 在 eslint 错误上构建失败?

转载 作者:行者123 更新时间:2023-12-01 00:17:15 53 4
gpt4 key购买 nike

我使用默认的 vue-cli 命令创建了一个 vue 项目。

webpack构建时失败,如图所示:

enter image description here

我没有使用任何特殊的 webpack 配置。我做错了什么?

我的package.json:

{
"name": "myapp",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.4.4",
"firebase": "^7.6.2",
"register-service-worker": "^1.6.2",
"vue": "^2.6.10",
"vue-router": "^3.1.3",
"vuex": "^3.1.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.1.0",
"@vue/cli-plugin-eslint": "^4.1.0",
"@vue/cli-plugin-pwa": "^4.1.0",
"@vue/cli-plugin-router": "^4.1.0",
"@vue/cli-plugin-vuex": "^4.1.0",
"@vue/cli-service": "^4.1.0",
"babel-eslint": "^10.0.3",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"node-sass": "^4.12.0",
"sass-loader": "^8.0.0",
"vue-template-compiler": "^2.6.10"
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}

最佳答案

您可以通过 webpack 配置强制 ESLint 始终仅发出警告而不是错误。这不会像您期望的那样停止您的构建。您需要在 webpack.config.js 文件中将 emitWarning 选项设置为 true 。例如。

module.exports = {
module: {
rules: [
{
test: /\.vue$/,
exclude: /node_modules/,
loader: "eslint-loader",
options: {
emitWarning: true
}
}
]
}
};

您可以在文档 https://github.com/webpack-contrib/eslint-loader#errors-and-warning 中阅读更多内容

关于javascript - 如何防止 webpack 在 eslint 错误上构建失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59683584/

53 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com