Module: Locomotive::Mounter::Extensions::Sprockets

Defined in:
lib/locomotive/mounter/extensions/sprockets.rb

Constant Summary collapse

@@env =
@@path = nil

Class Method Summary collapse

Class Method Details

.environment(site_path) ⇒ Object

Build a Sprocket environment for the current site. This method returns an unique environment for each call unless the site_path changed.

Parameters:

  • site_path (String)

    The root directory of the site



15
16
17
18
19
20
21
22
23
24
# File 'lib/locomotive/mounter/extensions/sprockets.rb', line 15

def self.environment(site_path)
  return @@env if @@env && @@path == site_path

  @@path  = site_path
  @@env   = ::Sprockets::Environment.new.tap do |env|
    %w(fonts stylesheets javascripts).each do |name|
      env.append_path File.join(site_path, 'public', name)
    end
  end
end