當我運行:Rails:找出哪個文件導致Sass :: SyntaxError異常?
rake assets:precompile RAILS_ENV=production --trace
我得到以下異常:
rake aborted!
Sass::SyntaxError: Invalid CSS after " */": expected "}", was ""
(sass):19419
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/scss/parser.rb:1179:in `expected'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/scss/parser.rb:1115:in `expected'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/scss/parser.rb:1110:in `tok!'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/scss/parser.rb:656:in `block'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/scss/parser.rb:647:in `ruleset'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/scss/parser.rb:673:in `block_child'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/scss/parser.rb:666:in `block_contents'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/scss/parser.rb:123:in `stylesheet'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/scss/parser.rb:39:in `parse'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/engine.rb:403:in `_to_tree'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sass-3.4.21/lib/sass/engine.rb:278:in `render'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sprockets-3.5.2/lib/sprockets/sass_compressor.rb:48:in `call'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sprockets-3.5.2/lib/sprockets/sass_compressor.rb:28:in `call'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:75:in `call_processor'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sprockets-3.5.2/lib/sprockets/processor_utils.rb:56:in `call_processors'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sprockets-3.5.2/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sprockets-3.5.2/lib/sprockets/loader.rb:60:in `block in load'
/Users/fernando/.rvm/gems/ruby-2.3.0/gems/sprockets-3.5.2/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
....
我如何找出導致該異常的文件嗎?在sass-rails中是否有一個選項來調試此問題?
注意:此應用程序的CSS/Javascript正在開發模式下工作。只有在生產中預編譯資產或運行rspec功能測試時纔會發生此異常。
注2:此問題只發生在config.css_compressor啓用。如果我禁用它,則資源預編譯沒有問題。
嘗試在開發中預編譯斷言,它應該給你導入這個問題的導入。另一種方法是在生產環境中檢查'application.css',並在#19419 –
檢查行中找到可能的重複項:http://stackoverflow.com/questions/10104865/best-practices-for-debugging-the-rails-asset-管道或http://stackoverflow.com/questions/23046447/how-do-you-know-what-line-contains-a-scss-error-when-using-import-in-rails-appl – cimmanon
@Dimitry_N錯誤只有在啓用了css壓縮器(不處於開發模式)時纔會發生。我試圖在生產環境中生成沒有壓縮器的CSS(它工作),然後檢查顯示錯誤的行。但第19419行是文件的結尾。 – Fernando