【问题标题】:Temporarily disable bootstrap during development?在开发过程中暂时禁用引导程序?
【发布时间】:2019-01-31 17:45:01
【问题描述】:

我正在使用 Bootstrap 在 Ruby on Rails 中开展我的第一个大型项目。它肯定会减慢所有加载速度。我怎样才能“关闭”引导程序,以便在我努力使我的视图正常工作时只查看基本文本,以便它们加载得更快?这样,当我准备好让它们再次看起来漂亮时,我可以“重新打开它”?

【问题讨论】:

    标签: ruby-on-rails twitter-bootstrap


    【解决方案1】:

    您可以评论您在清单文件中加载的文件,删除= 符号。 在app/assets/javascripts/application.js

     //= require bootstrap 
    

    改成

     // require bootstrap
    

    app/assets/stylesheets/application.scss

    *= require bootstrap/dist/css/bootstrap.min
    

    改成

    * require bootstrap/dist/css/bootstrap.min
    

    【讨论】:

      【解决方案2】:

      在头部注释标记为Bootstrap core CSSCustom styles for this template 的行以及底部的所有Bootstrap core Javascript,似乎大大加快了我的加载速度。

      我之前也注释掉了所有 IE hack 行。

      【讨论】:

        【解决方案3】:

        如果您通过 gem 使用引导程序(例如 bootstrap-rubygembootstrap-sass),那么另一种方法是仅在 :production 和/或 :test 环境中加载它。这样您就可以避免评论/注释掉require 语句的不便

        # Gemfile
        group :development do
        end
        
        group :test, :production do
          gem 'bootstrap-sass' # or whichever bootstrap gem
        end
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2012-12-23
          • 2014-01-26
          • 1970-01-01
          • 2011-01-08
          • 2016-05-04
          • 2015-08-07
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多