Remove a particular file/folder from the app tree depends upon the build environment


#1

I’m trying to remove a folder (app/utils/dev) from the app folder during the production build. I tried using broccoli-file-remover to remove the folder from app tree. But it’s not working for some reason :frowning:

appTree = removeFile(appTree, {
   path: 'app/utils/dev'
});

I think app tree will not maintain the app’s folder structure. But, I’m not sure.

Any suggestions?


Removing some files from a brocolli tree
#2

I think the easiest thing to do would be to using broccoli-funnel with an exclude pattern.

Complete pseudo code, but might look something like:

const Funnel = require('broccoli-funnel');
const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = require(defaults) {
  let trees = {};

  if (EmberApp.env() === 'production') {
    trees.app = new Funnel('app', {
      exclude: ['utils/dev/**'],
    });
  }

  let app = new EmberApp(defaults, {
    trees,
  });

  return app.toTree();
};

#3

Thanks for the suggestion @rwjblue will try it :+1:t2::+1:t2:


#4

:star_struck: that works perfectly with a small tweak, the key excludes doesn’t work but exclude does! However, it takes a while for me to recognize :stuck_out_tongue_closed_eyes:. Thanks a lot @rwjblue


#5

I updated Rob’s code sample above to remove the typo, to help future readers of this thread.