The Custom Wizard plugin creates its own Ember app and borrows some of the assets from the discourse core.
For that we use a js file called wizard-custom.js with sprockets directives targetting individual files.
In some cases, we require a lot of files from the same folder and were tempted to use require_tree for a long time but unfortunately, that isn’t possible due to the following reasons.
- The
wizard-custom.jsfile is located inside the plugin, so itsload pathis different from discourse and we can only require files inside theload path. - Sprockets doesn’t allow absolute paths when using
require_tree.
Solving this would also mean that the plugin breaks less often, due to changes in discourse core.
To mitigate this, we created a custom sprockets directive called require_tree_discourse which specifically looks up for assets inside the discourse folder using absolute paths. Here’s the PR containing that code.
Thought it would be interesting for discourse devs and rails devs in general out there.