0

在 config-overrides.js 中有这段代码

const rewireReactHotLoader = require('react-app-rewire-hot-loader')

module.exports = function override(config, env) {
  config = rewireReactHotLoader(config, env)
  config.target = 'es2020'
  config.resolve.alias = {
    ...config.resolve.alias,
    'react-dom': '@hot-loader/react-dom',
    hpscm: 'src/apps/hpscm',
    lut: 'src/apps/lut/src/apps/lut',
    shared: 'src/apps/lut/src/apps/shared',
    search: 'src/apps/search/src/apps/search',
    kbase: 'src/apps/kbase/src/apps/kbase',
    docflow: 'src/apps/docflow/src/apps/docflow',
  }

  return config
}

得到这个错误:

Failed to compile.

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.target should be one of these:
   "web" | "webworker" | "node" | "async-node" | "node-webkit" | "electron-main" | "electron-renderer" | "electron-preload" | function
   -> Environment to build for
   Details:
    * configuration.target should be one of these:
      "web" | "webworker" | "node" | "async-node" | "node-webkit" | "electron-main" | "electron-renderer" | "electron-preload"
    * configuration.target should be an instance of function

还检查了这个问题 configuration.module 有一个未知的属性 'loaders'

我的配置中没有“加载程序”,只有“规则”。找不到任何解决方案。有人也遇到过这个问题吗?

4

1 回答 1

0

需要更新 webpack 的版本以将目标设置为 es2020 https://webpack.js.org/configuration/target/

于 2021-04-30T11:46:14.237 回答