Class: Sprockets::UglifierCompressor

Inherits:
Tilt::Template
  • Object
show all
Defined in:
lib/sprockets/uglifier_compressor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.engine_initialized?Boolean

Returns:

  • (Boolean)

7
8
9
# File 'lib/sprockets/uglifier_compressor.rb', line 7

def self.engine_initialized?
  defined?(::Uglifier)
end

Instance Method Details

#evaluate(context, locals, &block) ⇒ Object


18
19
20
21
22
23
24
25
26
27
# File 'lib/sprockets/uglifier_compressor.rb', line 18

def evaluate(context, locals, &block)
  # Feature detect Uglifier 2.0 option support
  if Uglifier::DEFAULTS[:copyright]
    # Uglifier < 2.x
    Uglifier.new(:copyright => false).compile(data)
  else
    # Uglifier >= 2.x
    Uglifier.new(:comments => :none).compile(data)
  end
end

#initialize_engineObject


11
12
13
# File 'lib/sprockets/uglifier_compressor.rb', line 11

def initialize_engine
  require_template_library 'uglifier'
end

#prepareObject


15
16
# File 'lib/sprockets/uglifier_compressor.rb', line 15

def prepare
end