I'm a late arrival to the Bower scene. I thought I'd try it with my current Express project. I installed it, and created the .bowercc
and bower.json
file per instructions. I installed a Bootstrap skin I planned on using, which brought with it jQuery. The thing is, you get tons of files, and I'd like to use just the minified versions of JS, CSS and fonts.
After scowering the net, I found a lot about using gulp or grunt to sift through the files, and pipe them to the /public
folder Express provides. My question is: how do you do it properly? How do I get just the files I need there? Or am I better off foregoing bower and just downloading the zip file, picking up the end result and placing in the /public
folder?
Looking at the comments, it seems like the answer is yes - manual job is required to get your components distributeables to your
public
folder. Using gulp will automate it, but basically it'd be a hit-and-miss at first, requiring some fine tuning. In case someone lands on this question, here's the solution I went with:1) Provide package overrides in the bower.json file to ake sure only the minified files are exposed:
2) Use the
main-bower-files
gulp package to grab those "mains" and distribute them to the final locations. Here's my gulpfile.json (just the bower part:3) In your HTML file, include
/vendor/js/blah.min.js
or/vendor/css/blah.min.css
Note: the annoying part was that I had to specify every font extension in the
fontsFilter
. I tried using'**/fonts/*'
butmain-bower-files
returns a flat list of files, and if you provide the{base: 'mybase'}
parameter, it returns a tree, meaning you get the entire tree structure per file - anyone who can come up with a fix, is invited to submit an answer.