1
所以我正在構建應用程序&我已經添加了bootstrap-sass
寶石。這裏是我的Gemfile看起來是這樣的:Rails css資產管道沒有拉入其他樣式表。
gem 'rails', '4.2.6'
gem 'bootstrap-sass'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'bcrypt', '~> 3.1.7'
group :development, :test do
gem 'byebug'
gem 'sqlite3', '1.3.11'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
group :production do
gem 'pg'
end
我我的路線文件夾:
Rails.application.routes.draw do
root 'landing_page#home'
get 'users/new'
end
我有兩個樣式application.scss
& landing_page.scss
。
我只是試圖設計我的着陸頁。但是,我無法從我的landing_page.scss
中加載任何樣式。我只能得到這些樣式加載,如果放置在application.scss
。
這裏是application.scss
@import "bootstrap-sprockets";
@import "bootstrap";
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
@mixin box_sizing {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.debug_dump {
clear: both;
float: left;
width: 100%;
margin-top: 45px;
@include box_sizing;
}
body{
background-color: #525252;
}
任何人都知道我做錯了嗎?爲什麼在放入landing_page.scss
時沒有應用sass或簡單的css?
我完全明白如何部分功能,現在我的應用程序正常工作,所以非常感謝!我感興趣的是爲什麼這個樣式表必須導入,我認爲它最初是資產管道的一部分。還是因爲Sass的實現? – Nappstir
你問爲什麼'landing_page.scss'不包含在application.scss中? – kasperite
Sprocket(或資產管道)讀取清單文件以構建單個css或js文件。默認情況下,清單文件是application.css或application.scss。因此,您需要導入(或包含)其他css片段以供它們處理。請參閱http://guides.rubyonrails.org/asset_pipeline.html#manifest-files-and-directives。它回答你的問題嗎? – kasperite