Webpack 构建错误。无效的配置对象。目标参数无效
Webpack build error. Invalid configuration object. Invalid target param
配置中有此代码-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
也查过这个问题
我的配置中没有“加载器”,只有“规则”。找不到任何解决方案。有人也 运行 关注这个问题吗?
需要更新 webpack 版本以将目标设置为 es2020
https://webpack.js.org/configuration/target/
配置中有此代码-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
也查过这个问题
我的配置中没有“加载器”,只有“规则”。找不到任何解决方案。有人也 运行 关注这个问题吗?
需要更新 webpack 版本以将目标设置为 es2020 https://webpack.js.org/configuration/target/