我正在使用sass-rails和haml-rails寶石,這樣我就可以用HAML-sass風格編寫css文件。爲什麼耙子資產:預編譯產生一個空的CSS樣式表?
事情是當我想要生產並預編譯我的樣式表時,命令rake assets:precompile
無誤地運行,但生成的application.css爲空。
這是我的Gemfile:
source 'https://rubygems.org'
gem 'rails', '~>3.2'
gem 'pg', '>= 0.14'
gem 'haml-rails' #, '~> 0.3'
group :development, :test do
gem 'factory_girl_rails'
end
group :developpement do
gem 'rspec-rails', '>= 2.11'
gem 'capistrano', '>= 2.12'
gem 'faker', '>= 1.0'
gem 'rvm-capistrano'
end
group :test do
gem 'rspec', '>= 2.11'
gem 'webrat', '>= 0.7'
gem 'spork-rails', '>= 3.2'
end
group :assets do
gem 'sass-rails', '>= 3.2.3'
gem 'coffee-rails', '>= 3.2.1'
gem 'compass-rails', '>= 1.0'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'annotate'
gem 'excel_rails' #, '~> 0.3'
gem 'spreadsheet' #, '~> 0.7'
gem "schema_plus", :git => "git://github.com/lomba/schema_plus.git"
gem 'ar-octopus' #, '~> 0.3'
gem 'squeel' #, '~> 1.0'
gem 'devise' #, '~> 2.1'
gem 'role_model'
gem 'declarative_authorization'
gem 'rails-translate-routes' #, '~> 0.1'
gem 'validates_timeliness' #, '~> 3.0'
這是我的(空的)應用程序/資產/樣式表/ application.css.sass
/*
* 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 vendor/assets/stylesheets of plugins, if any, 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 top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*/
我刪除了以下注釋行按recommandation上https://github.com/rails/sass-rails:
*= require_self
*= require_tree .
我css.sass文件都存儲在這裏:
- 應用程序/資產/樣式表/ screen.css.sass
- 應用程序/資產/樣式表/分音/(很多諧音的文件_ *。css.sass通過screen.css.sass引用)
=== UPDATE ===
請注意我正在使用COMPASS gem。所以mixin和變量需要在樣式表之間共享。
以防萬一,這是我的應用程序/資產/ stylsheets/screen.css.sass文件:
// This import applies a global reset to any page that imports this stylesheet.
@import blueprint/reset
// To configure blueprint, edit the partials/base.sass file.
@import partials/base
@import blueprint/interaction
@import blueprint/typography
@import blueprint/grid
@import blueprint/buttons
@import blueprint/utilities
@import compass/layout/grid-background
@import compass/typography/lists/inline-block-list
@import compass/typography/lists/horizontal-list
@import compass/utilities/general/float
@import compass/css3/border-radius
@import compass/css3/box-shadow
@import compass/css3/text-shadow
@import compass/css3/transition
@import partials/opf_mixins_et_functions
@import partials/link_icons
@import partials/typo
@import partials/application
@import partials/affichage_donnees
@import partials/tableau_edition
@import partials/page
@import partials/form
@import partials/feedback
===更新2 ===
我意識到我的Gemfile會導致我在生產中遇到麻煩,因爲我把下面的寶石資產組在:
group :assets do
...
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
...
end
因爲生產 environnement以及需要一個JavaScript解釋器... 所以我會將它們移到我的Gemfile中的任何組之外。
任何意見,歡迎
你是否包括特定頁面上的樣式表?你有沒有設置你的環境文件來編譯嵌套在partials文件夾中的樣式表? – Ben 2013-03-21 19:55:08
我不明白你的問題。我得到了一個鐵軌的標準樣式表:screen.css.sass在App/assets/stylesheets partial目錄中提供了部分樣式表。我沒有修改任何環境文件。 – Douglas 2013-03-22 11:14:21