Gulp task to bundle bower_components?

JayPrime2012 picture JayPrime2012 · Apr 29, 2014 · Viewed 20.4k times · Source

I'd appreciate it so much if someone could please tell me a good way to handle bundling bower components. I feel like I've tried everything... Although, I can't seem to find any gulp tasks that handle this already. Could it really not exist?

Let's say it doesn't exist. Worst case scenario is I have to specify the paths of each "dist" file from bower_components folder. (It is annoying that each component seems to have its own "dist" folder... nothing is standardized.)

So even if I do that, I've noticed some components like 'active-support' seem to have require('lodash') and such in them. I think that if I just simply copy that file, it will break because the requires won't resolve.

What am I missing? How do I simply take all bower_components and bundle into a "common.js"... is there a way or is it a clusterfluck?

Answer

Brian Clozel picture Brian Clozel · Apr 30, 2014

Update

As pointed out by Alerty, the new Gulp policy seems to be: use bower directly and glob patterns (and hope that the packages maintainers have a proper "ignore" properties).


Previously

You can use main-bower-files or gulp-bower-src to get files from your bower components. They can also use "ignore" or "main" overrides in your own bower file.