【问题标题】:Possible to install just Bootstrap CSS with Bower?可以用 Bower 安装 Bootstrap CSS 吗?
【发布时间】:2014-01-27 06:01:45
【问题描述】:

通过 Yeoman 开始一个新的 Angular 项目会询问您是否要包含 Twitter Bootstrap(我使用的是 Sass 风格)。这样做包括样式和脚本。但是,我想使用 UI Bootstrap 而不是 Bootstrap 的脚本(依赖于 jQuery)。

那么,是否可以使用 Bower 仅安装 Bootstrap 的样式(最好在 Sass 中)?还是我只需要手动下载并包含 Bootstrap 样式?

【问题讨论】:

    标签: angularjs twitter-bootstrap bower angular-ui-bootstrap


    【解决方案1】:

    我知道 Bower 中有一个纯 CSS 的 Bootstrap 包:bootstrap-css-only;但是它带有预编译的 CSS 而不是 SASS。

    【讨论】:

    【解决方案2】:

    只需在 grunt bowerInstall 任务中添加exclude 选项,bowerInstall 任务不会将排除的文件注入到 html 文件中

    bowerInstall: {
      app: {
        src: ['<%= yeoman.app %>/index.html'],
        exclude: ['bower_components/bootstrap/dist/js/bootstrap.js'],
        ignorePath: '<%= yeoman.app %>/'
      }
    },
    

    【讨论】:

    • 你也可以排除 jQuery: 'bower_components/jquery/dist/jquery.js'
    【解决方案3】:

    基于此answer,您可以将其添加到.bowerrc 以删除Bootstrap JS 文件:

    { "directory": "bower_components", "scripts": { "postinstall": "rm -rf bower_components/bootstrap-sass-official/assets/javascripts" } }

    【讨论】:

      【解决方案4】:

      如果您的 gruntfile 中没有接受的答案中提到的 bowerInstall 任务,这也适用于wiredep 任务。

       wiredep: {
        app: {
          src: ['<%= yeoman.app %>/index.html'],
          exclude: ['bower_components/bootstrap/dist/js/bootstrap.js'],
          ignorePath:  /\.\.\//
        },
      

      【讨论】:

        【解决方案5】:

        你可以执行:

        bower install bootstrap-css-only
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-09-25
          • 1970-01-01
          • 2016-09-05
          • 1970-01-01
          • 1970-01-01
          • 2016-01-14
          • 1970-01-01
          相关资源
          最近更新 更多