FIX: Use Terser for minification even if uglify-js is not available (#13683)

This commit is contained in:
Kim Lindberger 2021-07-14 08:20:57 +02:00 committed by GitHub
parent 1fb48fc9a6
commit 7e52eada20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,7 @@ task 'assets:precompile:before' do
# is recompiled
Emoji.clear_cache
if !`which uglifyjs`.empty? && !ENV['SKIP_NODE_UGLIFY']
if !`which terser`.empty? && !ENV['SKIP_NODE_UGLIFY']
$node_uglify = true
end
@ -102,11 +102,8 @@ def compress_node(from, to)
source_map_url = cdn_path "/assets/#{to}.map"
base_source_map = assets_path + assets_additional_path
# TODO: Remove uglifyjs when base image only includes terser
js_compressor = `which terser`.empty? ? 'uglifyjs' : 'terser'
cmd = <<~EOS
#{js_compressor} '#{assets_path}/#{from}' -m -c -o '#{to_path}' --source-map "base='#{base_source_map}',root='#{source_map_root}',url='#{source_map_url}'"
terser '#{assets_path}/#{from}' -m -c -o '#{to_path}' --source-map "base='#{base_source_map}',root='#{source_map_root}',url='#{source_map_url}'"
EOS
STDERR.puts cmd