我正在使用Rails 3.1,在我的資產/樣式表中,我有一堆.css和.scss文件。爲什麼rails試圖預編譯.css文件
看來Rails正在試圖預編譯.css文件,他們炸燬了以下消息:
Invalid CSS after "...{padding-bottom": expected "{", was ";0;}#order_deta..."
如果我只有.css文件,如果我註釋掉的Gemfile然後一切正常青菜護欄寶石。
group :assets do
#gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
所以,現在的問題是,我不得不把所有的CSS轉換成.scss發揮與資產預編譯好的還是有解決方法嗎?
更新:
這裏是我的代碼:
config.assets.paths << "#{Rails.root}/app/themes/vanilla/assets/stylesheets"
config.assets.paths << "#{Rails.root}/app/themes/vanilla/assets/javascripts"
config.assets.paths << "#{Rails.root}/app/themes/vanilla/assets/images"
config.assets.precompile += ['vanilla.css', 'vanilla.js']
vanilla.css看起來是這樣的:
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. 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.
*
*= require 'reset'
*= require 'vroom'
*= require_self
*/
這裏復位reset.css和弗魯姆是vroom.css.scss
這是我得到的錯誤:
Invalid CSS after "...{padding-bottom": expected "{", was ";0;}#order_deta..."
(in .........../stylesheets/vanilla.css)
這個錯誤發生是因爲Rails試圖預編譯reset.css。
如果我刪除sass-rails gem和所有.scss文件,然後rake資產:預編譯工程。
您打算以後使用'sass-rails'嗎?如果沒有,看來這個評論是最好的方法。 – marcio
但正如我所說我有一些.css文件和一些.scss文件。我需要.scss的sass-rails。看起來應該很容易告訴sass-rails不能編譯.css。我肯定錯過了什麼。 –
什麼是拋出異常的文件的擴展名?您應該可以同時使用css和scss,而不會有任何問題。 – Nick