I wanted to open the discussion as to whether the default Webpacker configuration should take a stance on code-splitting, which can yield better build times and improved caching. There appear to be a few popular approaches, including using the CommonsChunkPlugin and the DllPlugin+DllReferencePlugin. The "Dll" approach appears to be more powerful but would impact the design of current Webpacker config more significantly.
Thoughts?
@rossta Hey, thanks for opening the discussion here. I have been thinking about chunking setup but didn't arrive to any final conclusion, mainly because of the varied use cases and probably this might make usage bit confusing i.e. adding an extra vendor file along with the pack file. At the moment common chunk setup lives in the Readme and there is no documentation on using DLL plugin. Perhaps we just document the usage? What do you think?
@javan Thanks for your thoughts. I can see your point about varied use cases and possible confusion. We're trying to evaluate how best to maintain our Webpack js config files as we add functionality and our config starts to diverge from the Webpacker generated config through gem version upgrades. For now, documentation and careful merges seem the simplest path forward. I'd be happy to submit README documentation if we decide to go ahead with the DLL plugin to support code splitting in our app.
I apologise for reviving a dead issue, but @rossta did you find any solutions that work well with Webpacker? Our application has grown, and it now takes around 90s for a complete rebuild, so we would like to split up the build process.
@lucaspiller We're currently using the CommonsChunkPlugin similar to what's documented in Webpacker. We haven't yet investigated the DLL plugin, but there was some discussion in #702 that may be helpful. No experience yet either with any async or on demand loading.
Any updates to this issue? I've got code splitting working for egghead.io with server-side rendering and Rails (Webpack v4, react-loadable, react-router v4). We're only using rails/webpacker for the view helpers. What's amazing about the code splitting is how the JS code knows just what JS and CS to load. So you don't have to put in the script tags for the used bundles. The setup uses React on Rails, including rails/webpacker.
Most helpful comment
@lucaspiller We're currently using the
CommonsChunkPluginsimilar to what's documented in Webpacker. We haven't yet investigated the DLL plugin, but there was some discussion in #702 that may be helpful. No experience yet either with any async or on demand loading.