-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a Webpacker v4 Upgrade Guide to docs #1905
Conversation
Credit to @justin808 for the original v4 upgrade guide this is based on.
@connorshea Great work! I think it would be good to mention |
@Zyphrax I don't fully understand that change unfortunately (I haven't really used the splitChunks config before), could you make a quick summary for me to include in the guide? |
@connorshea SplitChunks is a Webpack feature that avoids duplicate code by combining shared dependencies and including them only once. If you have script A that uses (e.g.) React and you have script B that uses React, then normally Webpack will merge React into script A and again into script B. With SplitChunks you can move the dependency (React) into a separate "chunk" and include it only once. A common configuration is to move all the node_modules dependencies into a vendors chunk. This will result in smaller js files and makes it easier for your browser to cache the relatively static vendor packages. Maybe it is a good idea to include these lines from the Usage instructions:
(I've added stylesheet_packs_with_chunks_tag to clarify what to use for stylesheets) |
fbabb85
to
1e0add3
Compare
@Zyphrax I've added a section on the change, does it look accurate to you? I've also added the config from #1755 (comment) |
@connorshea Yeah that looks great. Maybe we should link the "splitChunks API" to https://webpack.js.org/plugins/split-chunks-plugin/ - that page provides some useful examples on how to use it. |
Cursory look...LGTM. |
@connorshea For split chunks, https://github.com/rails/webpacker/blob/c4cf2e99c2ae4dffdd2942c1d2282936b8aaf36e/docs/webpack.md#add-splitchunks-webpack-v4 We have an option in the environment to setup splitchunks (officially suggested - https://twitter.com/wSokra/status/969633336732905474) but obviously, it's customisable. |
as an alternative to .browserlistrc file, I added it to the package that json like so. can we add this in the read me as well for those of us who don't want more files in our project? or is that file absolutely necessary @gauravtiwari |
@gauravtiwari should I just copy-paste that section into this upgrade guide? |
@arkhamRejek Sure, that's another option. @connorshea Yes please, just mention that we support the basic implementation out of the box (above the section) however it's customisable if need to be. Thanks :) |
@gauravtiwari you have access to my fork if you want to make that change and merge the PR ASAP, otherwise I can do it in about four hours :) |
Done, should be good to merge now :) |
We probably should add a few lines about the pack namespaces (added in RC6) to the upgrade guide.
@connorshea Do you still have the fork for a quick addition like this? |
@Zyphrax you can feel free to handle it |
See pull request: #1929 |
This is based on my experience upgrading my Rails app to v4.0.0-rc.5, plus some content taken from #1755.
Credit to @justin808 for the original v4 upgrade guide this is based on.