ran*_*891 1 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.
Run Code Online (Sandbox Code Playgroud)
这是我的 gemfile
# bootstrap
# gem 'bootstrap-sass', '3.3.7'
gem 'bootstrap', '~> 4.0.0.beta2'
gem 'jquery-rails', '4.3.1'
Run Code Online (Sandbox Code Playgroud)
我跑了
gem install bootstrap -v 4.0.0.beta2
Run Code Online (Sandbox Code Playgroud)
这是运行包更新的结果,我使用的是 sprockets-rails 2.3.2 版本。
Using sprockets 3.7.1
Using sprockets-rails 3.2.1
Using rails 5.1.4
Run Code Online (Sandbox Code Playgroud)
这是我在 app/assets/stylesheets/application.scss 中的内容
@import "bootstrap-sprockets";
@import "bootstrap";
@import "colors";
@import "font-awesome-sprockets";
@import "font-awesome";
Run Code Online (Sandbox Code Playgroud)
我的 application.js 文件
//
//= require jquery3
//= require jquery_ujs
//= require popper
//= require turbolinks
//= require tether
//= require bootstrap
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
如果我删除 @import "bootstrap-sprockets"; 从 application.scss web 应用程序出现,但我想知道它是否需要或为什么我收到错误。
Bootstrap Sprockets 提供了单独的 Bootstrap 组件以方便调试。
再次阅读bootstrap-rubygem 中的说明,您会注意到不应该导入 bootstrap-sprockets。
// app/assets/stylesheets/application.scss
@import "bootstrap-sprockets"; // Remove this line
然而,假设它需要一个javascript。这可以替换为仅引导程序的 require 以加快编译速度(您目前正在这样做)。
所以基本上,从 scss 中删除该行,你就很好了。