electron-userland / electron-webpack

Scripts and configurations to compile Electron applications using webpack
https://webpack.electron.build/
903 stars 170 forks source link

Custom webpack config gets into infinite loop #436

Closed pdkovacs closed 3 years ago

pdkovacs commented 3 years ago

N/A

webpack --mode development --debug --config custom.webpack.additions.js

never finishes and stack trace indicates that resolving electron-webpack/webpack.renderer.config.js recursively calls the custom webpack configurer:

image

loopmode commented 3 years ago

In electron-webpack, your custom config function receives the prepared config object, not an env. You don't call a function with it, but instead return it - modified or not. Webpack gets called then with the result of your function as its config.

pdkovacs commented 3 years ago

Thanks a lot for the quick response!

I followed the instructions here: https://webpack.electron.build/extending-as-a-library . Are these instructions for a package different from electron-webpack? Or are they for a different context?

loopmode commented 3 years ago

I believe it's just a misunderstanding, possibly the docs are not clear enough. But they're essentially correct. The question is whether you want to really use it as a library, and what that means. It would mean that you don't use electron-webpack "on the outside" but "on the inside" instead. The typical use case, yours probably as well, is to use electron-webpack as the build framework, with your app sitting inside of it, being built by it.

Using electron-webpack as a library would mean that your application has the larger setup and infrastructure, and inside of it runs electron-webpack, "as a library".

loopmode commented 3 years ago

That is.. maybe I'm leading you in the wrong direction and you actually do want to use it "as a library". The regular use case, what I advised you, is basically https://webpack.electron.build/modifying-webpack-configurations

pdkovacs commented 3 years ago

Thanks a lot for this!

Your assumption is correct (I think), my plan has been to build an application starting with electron-webpack-quick-start, I don't think I want to use electron-webpack as a library for now.