Webpack code-splitting produce wrong chunks paths
See original GitHub issuePreflight Checklist
- [x ] I have read the contribution documentation for this project.
- [ x] I agree to follow the code of conduct that this project follows, as appropriate.
- [x ] I have searched the issue tracker for a bug that matches the one I want to file, without success.
Issue Details
- Electron Forge Version:
- 6.0.0-beta.50
- Electron Version:
- 8.2.1
- Operating System:
- macOS 10.15.4
Expected Behavior
Webpack code chunks are resolved and loaded successfully in production mode
Actual Behavior
Webpack code chunks cannot be resolved and loaded in production mode (but in dev it works)
To Reproduce
- use react lazy-loading in your app (for example, make some
/page
route lazy-loading) - use webpack config without optimisation preferences
- run
electron-forge package
- check
out/name.app/Resources/app/.webpack/renderer
folder. - See
main_window/index.js
there - it’s an entry point of the app - See
1/index.js
there - as I understand, it’s a chunk of our splitted route - Run built app
- Go to
/page
route - Observe 404 error in console - it tries to load
renderer/main_window/1/index.js
instead ofrenderer/1/index.js
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
Webpack code-splitting produce wrong chunks paths #1612
I faced with the same issues, but fix above not working for me, I am still getting chunk loading error, for fix issue...
Read more >Code Splitting - webpack
Entry Points: Manually split code using entry configuration. Prevent Duplication: Use Entry dependencies or SplitChunksPlugin to dedupe and split chunks.
Read more >Webpack, new chunk is loading in with wrong path
bundle.js is an unnamed chunk created by code splitting. It will be placed in the output:path mentioned above but will be referred in...
Read more >The 100% correct way to split your chunks with Webpack
The idea behind bundle splitting is pretty simple. If you have one giant file, and change one line of code, the user must...
Read more >Code Splitting - webpack 3 documentation
Prevent Duplication: Use the CommonsChunkPlugin to dedupe and split chunks. Dynamic Imports: Split code via inline function calls within modules.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think I managed to make it work. I added this to my
webpack.renderer.config.js
output: { chunkFilename: 'main_window/[name].chunk.js', publicPath: '../', },
So what this does is create the files in the
main_window
directory entry, this alone would make webpack search for the filemain_window/main_window/0.chunk.js
and return 404. So I added thepublicPath
property to search outside that directory and make the paths coincide.@sebastianwd Thank you very much!