Class: Middleman::Extensions::MinifyJavascript

Inherits:
Middleman::Extension show all
Defined in:
middleman-core/lib/middleman-core/extensions/minify_javascript.rb

Overview

Minify Javascript Extension

Defined Under Namespace

Classes: Rack

Instance Attribute Summary

Attributes inherited from Middleman::Extension

#app, #options

Instance Method Summary (collapse)

Methods inherited from Middleman::Extension

activate, activated_extension, after_extension_activated, clear_after_extension_callbacks, config, helpers, option

Constructor Details

- (MinifyJavascript) initialize(app, options_hash = {}, &block)

Returns a new instance of MinifyJavascript



7
8
9
10
11
# File 'middleman-core/lib/middleman-core/extensions/minify_javascript.rb', line 7

def initialize(app, options_hash={}, &block)
  super

  app.config.define_setting :js_compressor, nil, 'Set the JS compressor to use. Deprecated in favor of the :compressor option when activating :minify_js'
end

Instance Method Details

- (Object) after_configuration



13
14
15
16
17
18
19
20
21
22
23
# File 'middleman-core/lib/middleman-core/extensions/minify_javascript.rb', line 13

def after_configuration
  chosen_compressor = app.config[:js_compressor] || options[:compressor] || begin
    require 'uglifier'
    ::Uglifier.new
  end

  # Setup Rack middleware to minify CSS
  app.use Rack, :compressor => chosen_compressor,
                :ignore     => Array(options[:ignore]) + [/\.min\./],
                :inline     => options[:inline]
end