Sha256: 211eb7862cc6165c2b2915a0471ca3caaf9b2d813a68b03742ab1d47e23b6c2c

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8

require 'uglifier'

module Nanoc3::Filters
  class UglifyJS < Nanoc3::Filter

    # Runs the content through [UglifyJS](https://github.com/mishoo/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
    #     }
    #   }
    #
    # @param [String] content The content to filter
    #
    # @option params [Array] :options ([]) A list of options to pass on to Uglifier
    #
    # @return [String] The filtered content
    def run(content, params={})
      # Add filename to load path
      Uglifier.new(params).compile(content)
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
nanoc3-3.2.4 lib/nanoc3/filters/uglify_js.rb
nanoc3-3.2.3 lib/nanoc3/filters/uglify_js.rb
nanoc3-3.2.2 lib/nanoc3/filters/uglify_js.rb
nanoc3-3.2.1 lib/nanoc3/filters/uglify_js.rb
nanoc3-3.2.0 lib/nanoc3/filters/uglify_js.rb
nanoc3-3.2.0b3 lib/nanoc3/filters/uglify_js.rb
nanoc3-3.2.0b2 lib/nanoc3/filters/uglify_js.rb
nanoc3-3.2.0b1 lib/nanoc3/filters/uglify_js.rb