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
ignore property but even then you may still get more than you need. Preens role is to remove any of those unwanted files/paths.
bower.json file has jquery as a dependency.
"name": "myProject""dependencies":"jquery": "~2.0.3"
which gives the following folder after running
bower.json with a preen property as follows
"name": "myProject""dependencies":"jquery": "~2.0.3""preen":"jquery":"*.js"
and then run
preen to end up with
The previous example will not work for newer versions of jquery such as 2.1.1 due to its updated folder structure
A more suitable
bower.json would look like
"name": "myProject""dependencies":"jquery": "~2.1.1""preen":"jquery":"dist/*.js"
As shown above configuration is done via the preen property of your
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
you can then run
preen if you are happy to go ahead
A verbose flag is also avaible to show the same level of detail as the actual preen is run
You can also add a directory flag to override bower's default directory (or the one set in .bowerrc). This can be useful when using preen as part of your build pipeline. Example:
preen --directory ./tmp/path/to/bower/root
while preen can be run via the command line it is well suited to running as a grunt task
preen can also be used in a gulp task (there is no need for preen to have gulp plugin). The below example would run preen (with no options set) before the default task.
var gulp =preen = ;gulp;gulp;
thanks to the following modules that make this one possible