preen unwanted files in packages installed via Bower

npm install preen
7 downloads in the last week
18 downloads in the last month


A Node.js module to preen unwanted files and folders from packages installed via Bower.

Bower is great but some times it gives you more than you need. These days many packages define paths that are not required in production via the bower.json files ignore property but even then you may still get more than you need. Preens role is to remove any of those unwanted files/paths.

A Basic Example

My projects bower.json file has jquery as a dependency.

  "name": "myProject",
  "dependencies": {
    "jquery": "~2.0.3"

which gives the following folder after running bower install

but all I really need for this project is the 4 javascript files. So I update my bower.json with a preen property as follows

  "name": "myProject",
  "dependencies": {
    "jquery": "~2.0.3"
  "preen": {
    "jquery": [

and then run preen to end up with


As shown above configuration is done via the preen property of your bower.json file. The preen data object expects properties for each bower installed package that is to be preened in the format

"<package>": ["<patern 1>", "<patern 2>", ...]

See Minimatch for an explanation of Minimatch patterns.

Any packages not listed will not be preened.


when running via the command line you can add a preview flag to see a list of all paths and if they will be deleted or kept preen --preview

you can then run preen if you are happy to go ahead

Grunt Task

while preen can be run via the command line it is well suited to running as a grunt task NPM


thanks to the following modules that make this one possible

  • async
  • bower
  • fs.extra
  • readdirp
  • minimatch
  • optimist

Release History

  • Aug 9, 2013 v1.0.0 preen and grunt-preen are ready to roll
npm loves you