discourse/app/assets/javascripts/discourse-plugins/colocated-template-compiler.js
David Taylor f5419521f0
DEV: Support colocation of component templates in plugins (#18598)
This allows plugins to colocate component JS and HBS under `/plugins/{name}/assets/javascripts/discourse/components`.

`discourse-presence` is updated to use this new pattern, which also serves as an integration test for this part of the build pipeline.
2022-10-17 09:38:20 +01:00

20 lines
537 B
JavaScript

const ColocatedTemplateProcessor = require("ember-cli-htmlbars/lib/colocated-broccoli-plugin");
module.exports = class DiscoursePluginColocatedTemplateProcessor extends (
ColocatedTemplateProcessor
) {
detectRootName() {
const entries = this.currentEntries().filter((e) => !e.isDirectory());
const path = entries[0]?.relativePath;
const match = path?.match(
/^discourse\/plugins\/(?<name>[^/]+)\/discourse\//
);
if (match) {
return `discourse/plugins/${match.groups.name}/discourse`;
}
}
};