While porting my code to webpacker-react I found it a bit tedious to "setup" every view component I have individually. I have many of them (which might not be the general case? dunno) used from different rails controllers. So I wanted to have components I use in the rails app automatically registered at pack level.
I think it's fairly common to have your react components divided into reusable components, VS "views", which are not reusable, possibly own global state via redux or alike, etc. As a result I structured my app/javascript/ folder like this:
This is a very valid use-case for non-SPA applications.
Feel free to submit a PR to implement this. One point to be careful about is how it interacts with hot-reloading.
Thanks for a great gem! :)
While porting my code to webpacker-react I found it a bit tedious to "setup" every view component I have individually. I have many of them (which might not be the general case? dunno) used from different rails controllers. So I wanted to have components I use in the rails app automatically registered at pack level.
I think it's fairly common to have your react components divided into reusable components, VS "views", which are not reusable, possibly own global state via redux or alike, etc. As a result I structured my
app/javascript/
folder like this:Now to register all views automatically, I have the following code in my pack:
I thought it would be nice to have things handled at webpacker-react level, via something like:
What do you think? Let me know if it's not generic enough for webpacker-react, I can totally understand that ;-)