mirror of
https://github.com/discourse/discourse.git
synced 2025-02-17 11:13:46 +08:00
FIX: reduce verboseness of uglify command
PERF: do not generate source maps in ruby mode
This commit is contained in:
parent
b06cb26f7f
commit
b279b1daa0
|
@ -11,8 +11,8 @@ task 'assets:precompile:before' do
|
||||||
puts "Purging temp files"
|
puts "Purging temp files"
|
||||||
`rm -fr #{Rails.root}/tmp/cache`
|
`rm -fr #{Rails.root}/tmp/cache`
|
||||||
|
|
||||||
if Rails.configuration.assets.js_compressor == :uglifier
|
if Rails.configuration.assets.js_compressor == :uglifier && !`which uglifyjs`.empty? && !ENV['SKIP_NODE_UGLIFY']
|
||||||
ENV["UGLIFY"] = "1"
|
$node_uglify = true
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Bundling assets"
|
puts "Bundling assets"
|
||||||
|
@ -21,11 +21,11 @@ task 'assets:precompile:before' do
|
||||||
# leaving very complicated build issues
|
# leaving very complicated build issues
|
||||||
# https://github.com/rails/sprockets-rails/issues/49
|
# https://github.com/rails/sprockets-rails/issues/49
|
||||||
|
|
||||||
# let's make precompile faster using redis magic
|
|
||||||
require 'sprockets'
|
require 'sprockets'
|
||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
|
|
||||||
|
|
||||||
|
if $node_uglify
|
||||||
# monkey patch asset pipeline not to gzip, compress: false is broken
|
# monkey patch asset pipeline not to gzip, compress: false is broken
|
||||||
class ::Sprockets::Asset
|
class ::Sprockets::Asset
|
||||||
# Save asset to disk.
|
# Save asset to disk.
|
||||||
|
@ -67,6 +67,7 @@ task 'assets:precompile:before' do
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -92,7 +93,12 @@ def compress_node(from,to)
|
||||||
|
|
||||||
source_map_root = (d=File.dirname(from)) == "." ? "/assets" : "/assets/#{d}"
|
source_map_root = (d=File.dirname(from)) == "." ? "/assets" : "/assets/#{d}"
|
||||||
|
|
||||||
STDERR.puts `uglifyjs '#{assets_path}/#{from}' -p relative -c -m -o '#{to_path}' --source-map-root '#{source_map_root}' --source-map '#{assets_path}/#{to}.map' --source-map-url '/assets/#{to}.map'`
|
cmd = "uglifyjs '#{assets_path}/#{from}' -p relative -c -m -o '#{to_path}' --source-map-root '#{source_map_root}' --source-map '#{assets_path}/#{to}.map' --source-map-url '/assets/#{to}.map'"
|
||||||
|
|
||||||
|
|
||||||
|
STDERR.puts cmd
|
||||||
|
`#{cmd} 2>&1`
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def compress_ruby(from,to)
|
def compress_ruby(from,to)
|
||||||
|
@ -127,7 +133,7 @@ task 'assets:precompile' => 'assets:precompile:before' do
|
||||||
# Run after assets:precompile
|
# Run after assets:precompile
|
||||||
Rake::Task["assets:precompile:css"].invoke
|
Rake::Task["assets:precompile:css"].invoke
|
||||||
|
|
||||||
if ENV["UGLIFY"]
|
if $node_uglify
|
||||||
puts "Compressing Javascript and Generating Source Maps"
|
puts "Compressing Javascript and Generating Source Maps"
|
||||||
manifest = Sprockets::Manifest.new(assets_path)
|
manifest = Sprockets::Manifest.new(assets_path)
|
||||||
manifest.files
|
manifest.files
|
||||||
|
@ -154,6 +160,6 @@ task 'assets:precompile' => 'assets:precompile:before' do
|
||||||
|
|
||||||
# protected
|
# protected
|
||||||
manifest.send :save
|
manifest.send :save
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user