Why does rails precompile task do non-digest assets

爱⌒轻易说出口 提交于 2019-12-21 17:28:54

问题


When I do: rake assets:precompile RAILS_ENV=production I get for example the following files in my public/assets folder:

  • application-7af6c31514bcdd4cce3c96892af4487f.js
  • application-7af6c31514bcdd4cce3c96892af4487f.js.gz
  • application.js
  • application.js.gz

The last 2 are a problem because it causes the compiled version to get served in development and I don't understand why they are being generated.

I have the following line in my production.rb:

config.assets.digest = true

回答1:


To stop the creation of the non-hashed filenames in public use:

rake assets:precompile:primary RAILS_ENV=production



回答2:


This is the normal behaviour of the asset compiler, the non-digest files are generated mainly for use in error pages and the like (where you don't have access to the MD5 hash) and there is currently no way to turn them off. Also, this question is virtually identical to this one: Rails compiles assets both with and without md5 hash, why?



来源:https://stackoverflow.com/questions/11007034/why-does-rails-precompile-task-do-non-digest-assets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!