LocTran016
LocTran016

Reputation: 25

configuration.module.rules[2] Issue in @electron-forge/plugin-webpack

Here is some info about the machine I'm using:

I'm trying to get my project here at: https://github.com/Cokaps/GenZOC working but I've ran to this issue:
When I run electron-forge start, it shows an error here:

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)

In my repo (link above), the config for electron forge is /forge.config.js, /webpack.js for main process and /webpack.renderer.js is for renderer. Is there anyway to fix this. I appreciate your help. Thanks

Edit: When I change rules.push in webpack.renderer.js to comment, it work but I want to find a fix for this.

Upvotes: 1

Views: 529

Answers (1)

Cokaps
Cokaps

Reputation: 43

Did you try loading like this in webpack.renderer.js:

const nativeRules = require('./webpack.rules.js');
// ...
 module: {
        rules: [
            nativeRules,
           // other rules that you want to load

Upvotes: 1

Related Questions