Using bootstrap with bower

Twitter BootstrapBower

Twitter Bootstrap Problem Overview


I'm trying to use bootstrap with bower, but since it clones the whole repo, there is no CSS and other stuff.

Does it means that I need to include building Bootstrap in my own build process? Or if I'm wrong, what's the right workflow?

Twitter Bootstrap Solutions


Solution 1 - Twitter Bootstrap

I finally ended using the following : bower install --save http://twitter.github.com/bootstrap/assets/bootstrap.zip

Seems cleaner to me since it doesn't clone the whole repo, it only unzip the required assests.

The downside of that is that it breaks the bower philosophy since a bower update will not update bootstrap.

But I think it's still cleaner than using bower install bootstrap and then building bootstrap in your workflow.

It's a matter of choice I guess.

Update : seems they now version a dist folder (see: https://github.com/twbs/bootstrap/pull/6342), so just use bower install bootstrap and point to the assets in the dist folder

Solution 2 - Twitter Bootstrap

There is a prebuilt bootstrap bower package called bootstrap-css. I think this is what you (and I) were hoping to find.

bower install bootstrap-css

Thanks Nico.

Solution 3 - Twitter Bootstrap

The css and js files are located within the package: bootstrap/docs/assets/

UPDATE:

since v3 there is a dist folder in the package that contains all css, js and fonts.


Another option (if you just want to fetch single files) might be: pulldown. Configuration is extremely simple and you can easily add your own files/urls to the list.

Solution 4 - Twitter Bootstrap

assuming you have npm installed and bower installed globally

  1. navigate to your project

  2. bower init (this will generate the bower.json file in your directory)

  3. (then keep clicking yes)...

  4. to set the path where bootstrap will be installed:
    manually create a .bowerrc file next to the bower.json file and add the following to it:

    { "directory" : "public/components" }

  5. bower install bootstrap --save

Note: to install other components:

 bower search {component-name-here}

Solution 5 - Twitter Bootstrap

I ended up going with a shell script that you should only really have to run once when you first checkout a project

#!/usr/bin/env bash

mkdir -p webroot/js
mkdir -p webroot/css
mkdir -p webroot/css-min
mkdir -p webroot/img
mkdir -p webroot/font

npm i
bower i

# boostrap
pushd components/bootstrap
npm i
make bootstrap
popd
cp components/bootstrap/bootstrap/css/*.min.css webroot/css-min/
cp components/bootstrap/bootstrap/js/bootstrap.js src/js/deps/
cp components/bootstrap/bootstrap/img/* webroot/img/

# fontawesome
cp components/font-awesome/css/*.min.css webroot/css-min/
cp components/font-awesome/font/* webroot/font/

Solution 6 - Twitter Bootstrap

Also remember that with a command like:

bower search twitter

You get a result with a list of any package related to twitter. This way you are up to date of everything regarding Twitter and Bower like for instance knowing if there is brand new bower component.

Solution 7 - Twitter Bootstrap

You have install nodeJs on your system in order to execute npm commands. Once npm is properly working you can visit bower.io. There you will find complete documentation on this topic. You will find a command $ npm install bower. this will install bower on your machine. After installing bower you can install Bootstrap easily.

Here is a video tutorial on that

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionxavier.seignardView Question on Stackoverflow
Solution 1 - Twitter Bootstrapxavier.seignardView Answer on Stackoverflow
Solution 2 - Twitter BootstrapTerry RoeView Answer on Stackoverflow
Solution 3 - Twitter BootstrapDziad BorowyView Answer on Stackoverflow
Solution 4 - Twitter BootstrapMahmoud ZaltView Answer on Stackoverflow
Solution 5 - Twitter BootstrapslfView Answer on Stackoverflow
Solution 6 - Twitter BootstrapjoaquindevView Answer on Stackoverflow
Solution 7 - Twitter Bootstrapasad khanView Answer on Stackoverflow