Admin? Public? How best to control visibility of Stimulus controller code

Does anyone have any best practices or tips on how to separate your code and manage manifest files when you want some Stimulus controllers only available to an admin area and some only available to a public area? Best I can think of right now is to have public or shared controllers live where they do by default and a subfolder for the admin area with a separate manifest file. Then when Rails generates a new controller, and updates the general manifest file, you do what’s needed to move the admin registration lines to the admin manifest file. Then in your separate application.js and admin.js files you require the pertinent manifest file.

Tedious but all I can think of right now.

Does anyone else do this or have better a way?


This is how I handle it as well. Now we know there are at least two of us out here that have this need. :slight_smile:

Maybe the stimulus generator could be modified with a new argument that would handle this? In addition I think the manifest:update rake task would also need to change.

Looking forward to hearing any better ways to handle this…