Ember,js. Modify app.js and vendor.js before the f

2019-08-22 04:10发布

问题:

I need to add some text in my final

app.js and vendor.js

but obvioulsy I need to modify them before the ember-cli-sri integrity https://ember-cli.com/user-guide/#subresource-integrity does its job.

How to do?

There are somewhere the pipeline steps?

Can I insert one step before the final one?

UPDATE

Now I'm building an in-repo-addon for modify the js before the final integrity step (with ember-cli-sri).

lib/modify-js-before-build/index.js

/* eslint-env node */
'use strict';

const replace = require('broccoli-replace');

module.exports = {
  name: 'modify-js-before-build',

  isDevelopingAddon() {
    return true;
  },

  postprocessTree(type, tree) {

    if (type !== 'all') {
      return tree;
    }

    return tree = replace(tree, {
      files: '*.js',
      patterns: [{
        match: /function/gm,
        replacement: "TESTTESTTEST"
      }]
    });

  }

};

lib/modify-js-before-build/package.json

{ ...,
"ember-addon": {
    "before": "ember-cli-sri"
  }
}

But I'm stucked here, I don't know how to do (I do not know very well broccoli). How can I tell it to add some text in my app.js and vendor.js before ember-cli-sri and other build steps?

I found this one: https://github.com/DockYard/ember-cli-one-script/blob/master/index.js. They are using broccoli-concat and broccoli-merge-trees. Something similar to me? But how?