utility to remove junk from
bower_components folder optimized for Polymer components.
Only files needed are left as specified in
bowerPurge.keep array. Use as a gulp task.
npm i bower-purge --save-dev
add configuration to your project
"bowerPurge":"deleteDir": "/test/" "/demo/""keep": "bower.json" ".html" ".js"
deleteDir is a list of folders to be deleted (folder name inside forward slashes / for
keep is a list of file path endings to be kept (for
DeleteDir runs first, so files matching
keep will be deleted in these folders.
Do NOT use
globs or wildcards.
use as gulp task
As a part of gulp build,
bower.json to build folder and run bower install.
the 'bower-purge' task must run in the build folder after bower install completes.
const bowerPurge = ;var buildFolder = 'your_build_folder';gulp;
advanced gulp example
install dependencies and cleanup after, in one gulp task
const bowerPurge = ;const install = ;const stripComments = ;const htmlmin = ; // can not minify JS ES6 because it uses uglifyJSconst pump = ;dest = 'your_build_folder';gulp;
before use, make a dry run to see what files will be deleted without actulally deleting them:
if you delete needed files, no worries, run
bower install to restore them. (if bower install does do nothing, delete
bower_components folder and run bower install again.)
in Windows CLI terminal, you can run
run.cmd see this file for CLI usage.