June 2021
Intermediate to advanced
398 pages
9h 35m
English
In development, we mostly worry about three things: writing our code, getting our code on to the page, and being able to recompile the code quickly and easily.
Somewhat uncharacteristically for Rails, Webpacker does not suggest any structure for your code beyond having the entry point be in app/packs/entrypoints. The important feature is that you can import files relative to either app/packs (for your own code) or node_modules (for third-party code).
That said, some suggestions:
Keep as little code as possible in your actual entry point; it should mostly just import things.
Where possible, having multiple modular small pack files is probably better than having a single one. (There’s a webpack optimization that makes ...