我正在使用Rails 4.2进行一个非常简单的项目.当我运行rake资产:预编译(用于开发和生产环境)时,我在public / assets中获得了application-xyz.js和application-xyz.css文件.但是不会创建gzip版本,即没有application-xyz.js.gz,也没有application-xyz.css.gz.我不知道有任何禁用此功能的选项.我错过了什么吗?
解决方法
链轮3不再生成gzip压缩版本的资产.根据
this issue,很大程度上是因为它们很少被实际使用.
您可以在预编译后通过gzipping资源自行恢复此功能,例如Xavier Noria使用find来使用find迭代资源文件夹中的所有css和js文件,然后使用xargs将它们传递给gzip:
namespace :deploy do # It is important that we execute this after :normalize_assets because # ngx_http_gzip_static_module recommends that compressed and uncompressed # variants have the same mtime. Note that gzip(1) sets the mtime of the # compressed file after the original one automatically. after :normalize_assets,:gzip_assets do on release_roles(fetch(:assets_roles)) do assets_path = release_path.join('public',fetch(:assets_prefix)) within assets_path do execute :find,". \\( -name '*.js' -o -name '*.css' \\) -exec test ! -e {}.gz \\; -print0 | xargs -r -P8 -0 gzip --keep --best --quiet" end end end end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。