Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit b420afc

Browse files
committed
Respect Rails assets env. for gzip compression
Skip gzip compression if it's disabled in Rails env.
1 parent 9008038 commit b420afc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/tasks/requirejs-rails_tasks.rake

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,15 @@ OS X Homebrew users can use 'brew install node'.
174174
requirejs.manifest[module_script_name] = digest_name
175175
FileUtils.cp built_asset_path, digest_asset_path
176176

177-
# Create the compressed versions
178-
File.open("#{built_asset_path}.gz", 'wb') do |f|
179-
zgw = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
180-
zgw.write built_asset_path.read
181-
zgw.close
177+
if requirejs.env.gzip?
178+
# Create the compressed versions
179+
File.open("#{built_asset_path}.gz", 'wb') do |f|
180+
zgw = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
181+
zgw.write built_asset_path.read
182+
zgw.close
183+
end
184+
FileUtils.cp "#{built_asset_path}.gz", "#{digest_asset_path}.gz"
182185
end
183-
FileUtils.cp "#{built_asset_path}.gz", "#{digest_asset_path}.gz"
184186

185187
requirejs.config.manifest_path.open('wb') do |f|
186188
YAML.dump(requirejs.manifest, f)

0 commit comments

Comments
 (0)