I'm currently trying Rails 6.0.0.rc1 which seems to have moved the default javascript
folder from app/assets/javascript
to app/javascript
. The application.js
file is now located in app/javascript/packs
. Now, I want to add a couple of js files, but for some reason they don't get imported and I can't find any documentation on how this can be done in Rails 6. I tried a couple of things:
Create a new folder
custom_js
underapp/javascript/packs
, putting all my js files there and then add arequire "custom_js"
toapplication.js
.Copy all my js files under
app/javascript/channels
(which should be included by default, sinceapplication.js
hasrequire("channels")
).Adding
require_tree .
toapplication.js
, which was the previous approach.
How can I load my own js files inside a Rails 6 application?