nanoc / features

Collection of feature requests
2 stars 1 forks source link

Customizable pruning #4

Open denisdefreyne opened 7 years ago

denisdefreyne commented 7 years ago

@agross wrote in nanoc/anoc#883:

Hi,

I actually have a question this time, this is not a problem report ;-)

I have some files that exist in the output directory that are created during compliation, but not by nanoc. For example, I have Sass generate a sourcemap next to the CSS file. Essentially, this is a filter that generated >1 output file (e.g. output/assets/css/foo-fp123.css and output/assets/css/foo-fp123.css.map).

Sass (Compass) also generates sprite images from nanoc items, so there also might be output/assets/images/sprites/icons-s123.png.

The nanoc pruner will delete these files by default because they are not known to nanoc as there's the 1 file in-1 file out convention.

I needed to extended nanoc.yaml like this:

prune:
  auto_prune: true
  exclude: ['sprites', 'css']
  • Is there an API to mark files as not to be pruned?
  • Are you open to extend the pruner excludes to be more flexible?

In my example above any path containing css will be exempt from pruning. I'd prefer a callback in the Rules, so I can decide on a case-by-case basis and support changing fingerprints, e.g. both icons-s123.png and icons-s456.png existing.

Further discussion in nanoc/nanoc#883.