mirror of
https://github.com/discourse/discourse.git
synced 2025-03-28 06:45:37 +08:00
add timings to asset precompile
This commit is contained in:
parent
b6e9c734f2
commit
d1b21aa73b
@ -110,7 +110,7 @@ end
|
|||||||
|
|
||||||
def gzip(path)
|
def gzip(path)
|
||||||
STDERR.puts "gzip -f -c -9 #{path} > #{path}.gz"
|
STDERR.puts "gzip -f -c -9 #{path} > #{path}.gz"
|
||||||
STDERR.puts `gzip -f -c -9 #{path} > #{path}.gz`
|
STDERR.puts `gzip -f -c -9 #{path} > #{path}.gz`.strip
|
||||||
raise "gzip compression failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
raise "gzip compression failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ def brotli(path)
|
|||||||
STDERR.puts brotli_command(path)
|
STDERR.puts brotli_command(path)
|
||||||
STDERR.puts `#{brotli_command(path)}`
|
STDERR.puts `#{brotli_command(path)}`
|
||||||
raise "brotli compression failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
raise "brotli compression failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
||||||
STDERR.puts `chmod +r #{path}.br`
|
STDERR.puts `chmod +r #{path}.br`.strip
|
||||||
raise "chmod failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
raise "chmod failed: exit code #{$?.exitstatus}" if $?.exitstatus != 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -179,9 +179,10 @@ task 'assets:precompile' => 'assets:precompile:before' do
|
|||||||
if File.exists?(_path)
|
if File.exists?(_path)
|
||||||
STDERR.puts "Skipping: #{file} already compressed"
|
STDERR.puts "Skipping: #{file} already compressed"
|
||||||
else
|
else
|
||||||
STDERR.puts "Compressing: #{file}"
|
|
||||||
|
|
||||||
proc.call do
|
proc.call do
|
||||||
|
start = Time.now
|
||||||
|
STDERR.puts "#{start} Compressing: #{file}"
|
||||||
|
|
||||||
# We can specify some files to never minify
|
# We can specify some files to never minify
|
||||||
unless (ENV["DONT_MINIFY"] == "1") || to_skip.include?(info['logical_path'])
|
unless (ENV["DONT_MINIFY"] == "1") || to_skip.include?(info['logical_path'])
|
||||||
FileUtils.mv(path, _path)
|
FileUtils.mv(path, _path)
|
||||||
@ -192,6 +193,9 @@ task 'assets:precompile' => 'assets:precompile:before' do
|
|||||||
info["mtime"] = File.mtime(path).iso8601
|
info["mtime"] = File.mtime(path).iso8601
|
||||||
gzip(path)
|
gzip(path)
|
||||||
brotli(path)
|
brotli(path)
|
||||||
|
|
||||||
|
STDERR.puts "Done compressing #{file} : #{(Time.now - start).round(2)} secs"
|
||||||
|
STDERR.puts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user