Using bootstrap with bower

前端 未结 7 1755
無奈伤痛
無奈伤痛 2021-01-30 05:45

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

相关标签:
7条回答
  • 2021-01-30 06:23

    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.

    0 讨论(0)
  • 2021-01-30 06:30

    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

    0 讨论(0)
  • 2021-01-30 06:31

    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

    0 讨论(0)
  • 2021-01-30 06:31

    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.

    0 讨论(0)
  • 2021-01-30 06:34

    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}
    
    0 讨论(0)
  • 2021-01-30 06:35

    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/
    
    0 讨论(0)
提交回复
热议问题