Linked Questions

Popular Questions

I have a broccoli plugin which does the following:

  • Read json file from root folder
  • based on the JSON generate some route template HBS files

This works perfectly and can also be acceptance tested by triggering a broccoli build.

Example result of the broccoli build:


The next phase is integrating it into an ember-addon, and I created one with a preprocessTree hook.

module.exports = {
  name: 'route-template-generator',

  included(app) {
    this._super.included.apply(this, arguments);

    this.options = Object.assign({}, app.options);
    this.appName =;

    if (!this.options.trees) {
        throw new Error('No trees found in app to add the new files to');
    if (!this.appName) {
        throw new Error('no valid application name, unable to add files to the tree');

  preprocessTree(type, tree) {
    if (type === 'template') {
      const extraTemplates = new RouteTemplateGenerator(
        [new Funnel(, { include: ['router.json'] })], 
        { destDir: this.appName }

      return mergeTrees([tree, extraTemplates], { overwrite: true });
    return tree;

The problem with above solution is that the trees cannot be merged if no destDir is passed. The ember-app tree is prefixed with the application name, e.g.:


When calling this addon immediately from a ember-app the will work, however when this addon is called as dependency from another addon, the parameter in the included hook gets an addon object which doesn't have the app tree name.

So the question is, how do I write files to an app tree the right way?

Related Questions