How to manage bower overweight?

To remove the cruft from libraries installed via bower I use ‘preen’, see https://github.com/braddenver/preen and documentation in readme.
Add the line "preen": "1.2.0", to your depencies in package.json and run npm install.
Modify your bower.json file and specify which files you want to keep, e.g. :

"preen": {
  "angular-cache": [
    "dist/angular-cache.min.js"
  ],
  "angular-google-maps": [
    "dist/angular-google-maps.min.js"
  ],
  "angular-moment": [
    "angular-moment.min.js"
  ],
  "angular-uuid4": [
    "angular-uuid4.min.js"
  ],
  "i18next": [
    "i18next.min.js"
  ],
  "lodash": [
    "lodash.min.js"
  ],
  "moment": [
    "min/moment-with-locales.min.js"
  ],
  "ng-i18next": [
    "dist/ng-i18next.min.js"
  ],
  "ngCordova": [
    "dist/ng-cordova.min.js"
  ],
  "underscore": [
    "underscore-min.js"
  ]
},

Add a gulp task to your gulpfile.js. Include the dependency
var preen = require('preen');

and specify the task

gulp.task('preen', function(cb) {
    preen.preen({}, cb);
});

From the command line run gulp preen
That’s it, all cruft is gone!

2 Likes