configuration.module.rules[2] @electron-forge/plugin-webpack 中的问题
2021-06-11
515
以下是有关我正在使用的机器的一些信息:
- Node v14.17.0
- Electron v13.1.2
- Win 10 21H1
- Yarn 2.4.2
我正尝试将我的项目放在:
https://github.com/Cokaps/GenZOC
工作,但我遇到了这个问题:
当我运行 electron-forge start 时,它在此处显示错误:
PS D:\GenZOC> yarn start
✔ Checking your system
✔ Locating Application
✔ Preparing native dependencies: 1 / 1
✔ Compiling Main Process Code
✖ Launch Dev Servers
An unhandled error has occurred inside Forge:
Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.module.rules[2] should be one of these:
["..." | object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?,
mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }, ...]
-> A rule.
Details:
* configuration.module.rules[2] should be "...".
* configuration.module.rules[2] should be an object:
object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }
-> A rule description with conditions and effects for modules.
ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.module.rules[2] should be one of these:
["..." | object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?,
mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }, ...]
-> A rule.
Details:
* configuration.module.rules[2] should be "...".
* configuration.module.rules[2] should be an object:
object { compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }
-> A rule description with conditions and effects for modules.
at validate (D:\GenZOC\node_modules\schema-utils\dist\validate.js:104:11)
at validateSchema (D:\GenZOC\node_modules\webpack\lib\validateSchema.js:78:2)
at create (D:\GenZOC\node_modules\webpack\lib\webpack.js:109:24)
at webpack (D:\GenZOC\node_modules\webpack\lib\webpack.js:151:32)
at f (D:\GenZOC\node_modules\webpack\lib\index.js:55:16)
at D:\GenZOC\node_modules\@electron-forge\plugin-webpack\src\WebpackPlugin.ts:296:24
at processTicksAndRejections (internal/process/task_queues.js:95:5)
在我的 repo(上面的链接)中,electron forge 的配置是
/forge.config.js
、
/webpack.js
用于主进程,
/webpack.renderer.js
用于渲染器。
有没有什么办法可以修复这个问题?感谢您的帮助。谢谢
编辑:当我将 webpack.renderer.js 中的
rules.push
更改为注释时,它可以工作,但我想找到一个解决方案。
1个回答
您是否尝试过在 webpack.renderer.js 中像这样加载:
const nativeRules = require('./webpack.rules.js');
// ...
module: {
rules: [
nativeRules,
// other rules that you want to load
Cokaps
2021-06-11