有没有办法忽略 Vue 构建中资产的错误?

Is there a way of ignoring errors for assets on Vue build?

我正在构建一个包含一些静态文件的 Vue 项目。为了在本地提供服务,我将其设置为 package.json:

{
  ...
  "eslintConfig": {
    ...
    "ignorePatterns": [
      "**/vendor/*.js"
    ]
  }
  ...
}

而且效果很好。但是当我尝试使用 npm run build 构建它时,我得到以下信息:

-  Building for production...
[BABEL] Note: The code generator has deoptimised the styling of /app/src/assets/vendor/fontawesome-free-5.15.3-web/js/all.min.js as it exceeds the max of 500KB.
 ERROR  Failed to compile with 2 errors

 error  in ./src/assets/vendor/bootstrap-4.6.0/bootstrap.bundle.min.js

Module Error (from ./node_modules/thread-loader/dist/cjs.js):

/app/src/assets/vendor/bootstrap-4.6.0/bootstrap.bundle.min.js
  6:144    error  'define' is not defined           no-undef
  6:157    error  'define' is not defined           no-undef
  6:234    error  'globalThis' is not defined       no-undef
  6:723    error  'a' is a function                 no-func-assign
  6:27968  error  Empty block statement             no-empty
  6:36778  error  Unnecessary escape character: \-  no-useless-escape
  6:37519  error  Unnecessary escape character: \-  no-useless-escape
  6:68065  error  'n' is defined but never used     no-unused-vars

✖ 8 problems (8 errors, 0 warnings)

这 2 个错误是针对这些资产的,两者都很相似。有没有办法在构建时跳过这些错误?这似乎只是一个 linting 问题。

如果你的配置文件包含这条语句,你可以尝试把这行注释掉:

"extends": "eslint:recommended"