How can I use Bower to pull in only the files I want? (e.g. just the .js file, no docs, tests, etc)

StackOverflow https://stackoverflow.com/questions/22269650

  •  11-06-2023
  •  | 
  •  

Question

I'm using bower to pull in css and js libraries that I'm using but I've bumped into a little bit of trouble when it comes to consistency. But first a little on my asset pipeline management:

I'm using laravel's asset pipeline package which looks in specific directories for the appropriate .js/.css files and minifies it in production. So I need myapp/lib/javascripts/ to store all only jquery.js, angular.js, foundation.js. Same for my .css as well.

Currently I've been copying it over manually, but I want to be able to automate this on a single bower update. Is this possible with the tools I use currently (laravel or bower)?

Different vendors have inconsistent folder structures (e.g. typeahead/dist/typeahead.bundle.js).

Was it helpful?

Solution

Quick answer: you don't use Bower for that.

Bower is a package manager and will grab the distribution as the author defines it. You can define the location where it saves the packages but not cherry pick individual files.

You are missing a build manager / build script that can (among other things) copy files from one location to another. By far the most popular are Grunt and Gulp.

I would highly recommend taking the time to learn and integrate one of these tools into your workflow.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top