Rails升级到bootstrap 4

时间:2017-12-02 02:38:42

标签: ruby-on-rails bootstrap-4

我目前正在使用bootstrap 3.3.7并尝试升级到4.0.0.beta2但是在完成本教程之后https://github.com/twbs/bootstrap-rubygem我收到以下错误。

ActionView::Template::Error (File to import not found or unreadable: bootstrap-sprockets.

这里是我的宝石文件

# bootstrap
# gem 'bootstrap-sass', '3.3.7'
gem 'bootstrap', '~> 4.0.0.beta2'
gem 'jquery-rails', '4.3.1'

我跑了

gem install bootstrap -v 4.0.0.beta2

在运行捆绑包更新时,我使用了sprockets-rails 2.3.2版本。

Using sprockets 3.7.1
Using sprockets-rails 3.2.1
Using rails 5.1.4

这是我在app / assets / stylesheets / application.scss

中的内容
@import "bootstrap-sprockets"; 
@import "bootstrap";
@import "colors";
@import "font-awesome-sprockets";
@import "font-awesome";

我的application.js文件

//
//= require jquery3
//= require jquery_ujs
//= require popper
//= require turbolinks
//= require tether
//= require bootstrap
//= require_tree .

如果我删除@import" bootstrap-sprockets&#34 ;;从application.scss Web应用程序出现,但我想知道它是否需要或为什么我得到错误。

1 个答案:

答案 0 :(得分:4)

  

Bootstrap Sprockets提供单独的Bootstrap组件,以便于调试。

再次阅读bootstrap-rubygem中的说明,您会注意到没有假设是bootstrap-sprockets的导入。

// app/assets/stylesheets/application.scss @import "bootstrap-sprockets"; // Remove this line

然而,假设有一个javascript需要它。这可以替换为仅用于引导的需求,以便更快地进行编译(您目前正在进行编译)。

所以基本上,从scss中删除该行,你就是好的。