rails 6 where to put javascript files

There’s a section specifying where to put js files on the documentation https://github.com/rails/webpacker#paths. You can put the files anywhere, if you put them inside the packs folder webpacker will create bundles using those files, if you put them elsewhere wenpacker will bundle them inside the packs that require them.

wenpacker will bundle them inside the packs that require them

What does that mean?

If you have a file inside /packs called application.js that has a line “import Something from ‘…/some_js’”, webpacker will include the code from “some_js.js” inside the resulting bundle “application.js”.