2015-10-16 34 views
0

我遇到了外部程序包的html文件中的一些壞CSS損壞了我的Rails項目的rake assets:precompile的情況。我瞭解預編譯依賴關係是有目的的,也是一個好主意(只要它們沒有錯誤就通過),而且我不確定當外部包打破你的資產時標準協議是什麼。從外部打包的HTML文件中的壞CSS在Rails資產管道中打破預編譯

打破資產:

node_modules/browserify/node_modules/browserify-zlib/node_modules/pako/doc/index.html 

錯誤:

Sass::SyntaxError: Invalid CSS after " background": expected comma, was ": -moz-linear-g..." (sass):192 

我有我怎麼可能這樣做一對夫婦的想法:

  1. 限制預編譯到應用程序/資產/ * (不要預編譯寶石和外部依賴)
  2. 排除html文件fr om預編譯(我對從html文件獲取CSS錯誤感到困惑) - 但是我仍然可能從外部程序包中獲得其他文件類型的錯誤
  3. 排除node_modules中的任何內容 - 我不知道如何執行此操作在實踐中。

得到我:

p Rails.application.config.assets.paths 
["/myapp/app/assets/images", 
"/myapp/app/assets/javascripts", 
"/myapp/app/assets/stylesheets", 
"/myapp/vendor/assets/javascripts", 
"/myapp/vendor/assets/stylesheets", 
"/usr/local/bundle/gems/rails-assets-speakingurl-6.0.0/app/assets/javascripts", 
"/usr/local/bundle/gems/rails-assets-speakingurl-6.0.0/app/assets/templates", 
"/usr/local/bundle/gems/rails-assets-dropzone-4.0.1/app/assets/javascripts", 
"/usr/local/bundle/gems/rails-assets-dropzone-4.0.1/app/assets/stylesheets", 
"/usr/local/bundle/gems/rails-assets-mailcheck-1.1.1/app/assets/documents", 
"/usr/local/bundle/gems/rails-assets-mailcheck-1.1.1/app/assets/images", 
"/usr/local/bundle/gems/rails-assets-mailcheck-1.1.1/app/assets/javascripts", 
"/usr/local/bundle/gems/rails-assets-backbone-1.1.2/app/assets/javascripts", 
"/usr/local/bundle/gems/rails-assets-backbone-1.1.2/app/assets/templates", 
"/usr/local/bundle/gems/rails-assets-underscore-1.8.3/app/assets/javascripts", 
"/usr/local/bundle/gems/rails_admin-0.7.0/app/assets/images", 
"/usr/local/bundle/gems/rails_admin-0.7.0/app/assets/javascripts", 
"/usr/local/bundle/gems/rails_admin-0.7.0/app/assets/stylesheets", 
"/usr/local/bundle/gems/nested_form-0.3.2/vendor/assets/javascripts", 
"/usr/local/bundle/gems/jquery-ui-rails-5.0.5/app/assets/images", 
"/usr/local/bundle/gems/jquery-ui-rails-5.0.5/app/assets/javascripts", 
"/usr/local/bundle/gems/jquery-ui-rails-5.0.5/app/assets/stylesheets", 
"/usr/local/bundle/gems/font-awesome-rails-4.4.0.0/app/assets/fonts", 
"/usr/local/bundle/gems/font-awesome-rails-4.4.0.0/app/assets/stylesheets", 
"/usr/local/bundle/gems/remotipart-1.2.1/vendor/assets/javascripts", 
"/usr/local/bundle/gems/selectize-rails-0.12.1/vendor/assets/javascripts", 
"/usr/local/bundle/gems/selectize-rails-0.12.1/vendor/assets/stylesheets", 
"/usr/local/bundle/gems/codemirror-rails-5.5/vendor/assets/javascripts", 
"/usr/local/bundle/gems/codemirror-rails-5.5/vendor/assets/stylesheets", 
"/usr/local/bundle/gems/jquery-rails-4.0.4/vendor/assets/javascripts", 
"/usr/local/bundle/gems/coffee-rails-4.1.0/lib/assets/javascripts", 
"/usr/local/bundle/gems/bootstrap-sass-3.3.5.1/assets/stylesheets", 
"/usr/local/bundle/gems/bootstrap-sass-3.3.5.1/assets/javascripts", 
"/usr/local/bundle/gems/bootstrap-sass-3.3.5.1/assets/fonts", 
"/usr/local/bundle/gems/bootstrap-sass-3.3.5.1/assets/images", 
"/usr/local/bundle/gems/font-awesome-sass-4.4.0/assets/stylesheets", 
"/usr/local/bundle/gems/font-awesome-sass-4.4.0/assets/fonts"] 
+0

唯一的解決方法是手動編輯您要更改的文件。您將無法在生產中調用該文件,預編譯的重點在於確保您的所有文件都保存在您的應用程序本地。 –

+0

這是我部署Docker後的問題,由於容器是暫時的,重新安裝依賴關係,並在每個構建中重新創建文件。手動更改文件是不可能的。 –

回答

0

嘗試升級(或降級)您的'青菜-Rails的寶石。

不要忘記在安裝軟件包後重新啓動服務器。

0

該問題已解決,需要通過Browserify而不是Sprockets(這是從一開始的意思,但application.js有一個小錯誤)的依賴關係。我不再從文件中獲取CSS錯誤,因爲它不經過資產管道。

相關問題