Webpacker and "config" file organization

Rails would benefit from a canonical more logical locating of folders and files in Webpacker. I followed several articles and not knowing what I was doing, now have this, some of which needs to be refactored, but it works and I spent enough time on in.

/app/javascript/stylesheets/documents.scss
/app/javascript/src/some.js
/app/javascript/packs/more.js
/app/javascript/yet_more.js

.scss in a javascript folder? Differences in the three JS file locations?

Secondly is having package.json and other .json at the top level. I guess one could ask why Gemfile is top level and routes is not.

2 Likes

Thanks for this feedback!

There’s a coordinated effort going on to improve the documentation around this. You can look for updates here:

JavaScript Documentation Coordination

Second this one in particular. The default app directory gives me a pretty good starting point for me to organise most of my Rails code. app/javascript feels like an intimidating blank slate.

Sprockets had its drawbacks, but the structure it provided felt pretty intuitive and Rails-y