Removing some files from a brocolli tree


#1

I asked this question on StackOverflow but there hasn’t been any answers so I thought I’d ask again here:

I am using ember-cli and broccoli.

A tree is generated containing all of the files from my application. This tree is passed to broccoli-manifest to generate a HTML5 application cache manifest file. However, I would like to exclude some of the files from being written to the manifest (they shouldn’t be available offline - a FALLBACK is instead specified in the manifest).

My first thought was to submit a pull request to broccoli-manifest allowing you to pass an option containing a list of files to ignore (e.g. not output into the manifest).

Then it occurred to me that perhaps a more broccoli way to approach it would be to somehow filter the tree before passing it in to broccoli-manifest.

e.g. something like:

var completeTree = app.toTree();
var filteredTree = imaginaryFilteringFunction(completeTree, {
  exclude: ['assets/is-online.json']
});
module.exports = mergeTrees([completeTree, writeManifest(filteredTree, {
  fallback: ['assets/is-online.json assets/offline.json']
})]);

Does something like my imaginaryFilteringFunction exist in broccoli land? Should it? Or should I go about this in a different way?


#2

Use broccoli-file-remover.

Removing a single file from app/ (named main.js):

var removeFile = require('broccoli-file-remover');

var tree = removeFile('app', {
  srcFile: 'app/main.js'
});

#3

Perfect! Thanks so much for the speedy reply :smile: I knew there must be something but couldn’t find it in my googling!


#4

I tried this for some of my Ember files without success. Is there something going on here during compilation that prevents removing files in the Ember tree? For example, how might I exclude and Ember controller, or route file?


#5

I too can’t able to shake the paths out of the build using the broccoli-file-remover Is this addon out dated?


#6

This thread is super old, and unrelated to filtering files out before ember-cli’s build pipeline (the question asked was how to filter out files in postprocessTree which is effectively at the end of the build pipeline).

I’d suggest starting a new thread, specifically about your current question. The answer should be straightforward. :smile_cat:


#7

@rwjblue thanks for your time. Started a separate thread here