Add option to emit file in @loadble/webpack-plugin
See original GitHub issue🚀 Feature Proposal
Using @loadable
in server rendered apps using webpack-dev-server that keeps output in memory is not working very well right now. One way to solve this would be to have an option to emit the file to disk.
I don’t have any knowledge regarding the webpack API and if it’s safe or not to do this. However I know there are atleast two webpack plugins that does this today already.
- https://github.com/danethurber/webpack-manifest-plugin
- https://github.com/ztoben/assets-webpack-plugin
Motivation
I think think library is awesome and I’ve spent a couple of days implementing @loadable
into our frontend platform. It works great but we also were in the process of switching build-system to razzle
and that’s where I ran into a wall.
Razzle runs two instances of webpack (one for the server and one for the client). The client side of webpack generates the loadable-stats.json
file and is kept in memory during development (razzle start
). It’s currently very hard for the server to get a hold of this file…
Example
I’ve forked the @loadable/webpack-plugin
and made some quick changes that seems to work well for us. As previously stated, I don’t know the implications of doing it like I have. I would need to get familiar with the webpack plugins API to tackle this issue.
Here’s a gist of the changes I’ve done: https://gist.github.com/marcneander/2bddd49fd3bd8c6065d8e51b221168a4
Right now I’m not capable of doing much coding outside of work. I might be able to convince my manager to let me spend a few hours on this.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:7 (7 by maintainers)
Top GitHub Comments
Was just creating exact same thing https://gist.github.com/dlebedynskyi/7fd345f3d193bb78790c0e122e23012c
a bit more checks based on https://github.com/themgoncalves/react-loadable-ssr-addon/blob/master/source/ReactLoadableSSRAddon.js
also switch to emitAsync to handle error during file write - like EACCESS etc. Otherwise errors are swallowed
Already done!