简体   繁体   中英

How can I access currently processed Broccoli trees from an addon's index.js file?

I am working on a new in-repo addon, and I want to copy a file from the public tree to my own addon's namespace.

I've specified that my addon should run after broccoli-asset-rev , because the file I want is the assetMap.json file generated by this plugin.

I've been able to use treeForAddon to write new files to my own addon's namespace (which I can then import in my application code), but my question is, can I read from the currently-built public tree in this hook? Ideally I'd like to do something like this:

module.exports = {
  name: 'my-new-addon',

  treeForAddon() {
    let publicTree = this.getTreeFor('public'); // does something like this exist?
    let newTree;

    // Read assets/assetMap.json from the public tree, and
    // write it to a file called asset-map.json in newTree

    return this._super.treeForAddon.call(this, newTree);
  }
};

That would allow me to do the following in my Ember app code:

import assetMap from 'my-new-addon/asset-map';

Is it possible?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM