Skip to content

Instantly share code, notes, and snippets.

@mkoryak
Last active October 30, 2015 14:18
Show Gist options
  • Save mkoryak/6a1619bf7a84a1bb789f to your computer and use it in GitHub Desktop.
Save mkoryak/6a1619bf7a84a1bb789f to your computer and use it in GitHub Desktop.
wiredep - respect child dependencies' bower overrides
/*
this hack fixes the following issues:
https://github.com/taptapship/wiredep/issues/149
https://github.com/taptapship/wiredep/issues/183
be aware that:
- this will take overrides from everything in your BOWER_PATH,
even packages that you might not depend on
- overrides in your bower.json win
packages this requires:
var glob = require('glob');
var _ = require('underscore');
var wiredep = require('wiredep').stream;
var gulp = require('gulp');
*/
var BOWER_PATH = './bower_components';
var COMPILE_PATH = './compiled';
gulp.task("wiredep", function() {
return gulp.src(COMPILE_PATH + "/index.html").pipe(wiredep({
directory: BOWER_PATH,
overrides: (function() {
var configs = glob.sync(BOWER_PATH + "/**/bower.json");
var overrides = {};
_.each(configs, function(cpath) {
return _.extend(overrides, require(cpath).overrides || {});
});
_.extend(overrides, require(path.join(__dirname, "bower.json")).overrides || {});
return overrides;
}())
})).pipe(gulp.dest(COMPILE_PATH));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment