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.

1 Like

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

Based on other posts and blogs I’ve changed to /app/webpacker/ as the folder. As well as being more logical, IMHO; a beneficial side affect (although trivial) is that now /views and /webpacker are right next to each other which helps in text editors.

Now we need to find another name for controller, so all four (MVC and webpacker) are together. Kidding.

1 Like

/wayfinders ?

:sunglasses:

Walter

1 Like

Less severe sounding than controllers. VWMW.

I also encounter the same problem. Thanks for the information.

myccpay