Module: Middleman::Features::AssetHost

Defined in:
lib/middleman/features/asset_host.rb

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object Also known as: included



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/middleman/features/asset_host.rb', line 3

def registered(app)
  app.after_feature_init do
    if Middleman::Server.asset_host.is_a?(Proc)
      ::Compass.configuration.asset_host(&Middleman::Server.asset_host)
    end
  end

  Middleman::Assets.register :asset_host do |path, prefix, request|
    original_output = Middleman::Assets.before(:asset_host, path, prefix, request)

    valid_extensions = %w(.png .gif .jpg .jpeg .js .css)

    asset_prefix = Middleman::Server.asset_host.call(original_output)

    File.join(asset_prefix, original_output)
  end
end