Class: Nanoc3::Filters::UglifyJS

Inherits:
Nanoc3::Filter show all
Defined in:
lib/nanoc3/filters/uglify_js.rb

Constant Summary

Constant Summary

Constants inherited from Nanoc3::Filter

Nanoc3::Filter::TMP_BINARY_ITEMS_DIR

Instance Attribute Summary

Attributes inherited from Nanoc3::Filter

#assigns

Instance Method Summary (collapse)

Methods inherited from Nanoc3::Filter

#depend_on, #filename, from_binary?, #initialize, #output_filename, to_binary?, type

Methods included from PluginRegistry::PluginMethods

#identifier, #identifiers, #named, #register

Methods inherited from Context

#get_binding, #initialize

Constructor Details

This class inherits a constructor from Nanoc3::Filter

Instance Method Details

- (String) run(content, params = {})

Runs the content through UglifyJS. This method optionally takes options to pass directly to Uglifier:

{ :mangle => true, # Mangle variables names :toplevel => false, # Mangle top-level variable names :except => [], # Variable names to be excluded from mangling :max_line_length => 32 * 1024, # Maximum line length :squeeze => true, # Squeeze code resulting in smaller, but less-readable code :seqs => true, # Reduce consecutive statements in blocks into single statement :dead_code => true, # Remove dead code (e.g. after return) :unsafe => false, # Optimizations known to be unsafe in some situations :copyright => true, # Show copyright message :beautify => false, # Ouput indented code :beautify_options => { :indent_level => 4, :indent_start => 0, :quote_keys => false, :space_colon => 0, :ascii_only => false } }

Parameters:

  • content (String)

    The content to filter

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :options (Array) — default: []

    A list of options to pass on to Uglifier

Returns:

  • (String)

    The filtered content



36
37
38
39
# File 'lib/nanoc3/filters/uglify_js.rb', line 36

def run(content, params={})
  # Add filename to load path
  Uglifier.new(params).compile(content)
end