class Locomotive::Steam::SprocketsEnvironment

Attributes

steam_path[R]

Public Class Methods

new(root, options = {}) click to toggle source
Calls superclass method
# File lib/locomotive/steam/initializers/sprockets.rb, line 16
def initialize(root, options = {})
  super(root)

  @steam_path = root

  append_steam_paths

  install_minifiers if options[:minify]

  install_autoprefixer

  context_class.class_eval do
    def asset_path(path, options = {})
      path
    end
  end
end

Public Instance Methods

asset_path(path, options = {}) click to toggle source
# File lib/locomotive/steam/initializers/sprockets.rb, line 28
def asset_path(path, options = {})
  path
end

Private Instance Methods

append_steam_paths() click to toggle source
# File lib/locomotive/steam/initializers/sprockets.rb, line 36
def append_steam_paths
  %w(fonts stylesheets javascripts).each do |name|
    append_path File.join(@steam_path, name)
  end

  Compass::Frameworks::ALL.each { |f| append_path(f.stylesheets_directory) }
end
install_autoprefixer() click to toggle source
# File lib/locomotive/steam/initializers/sprockets.rb, line 50
def install_autoprefixer
  file = File.join(root, '..', 'config', 'autoprefixer.yml')

  if File.exists?(file)
    params = (::YAML.load_file(file) || {}).symbolize_keys
    AutoprefixerRails.install(self, params)

    Locomotive::Common::Logger.info "[Autoprefixer] detected and installed".light_white

    if ENV['EXECJS_RUNTIME'].blank?
      Locomotive::Common::Logger.warn "[Autoprefixer]".light_white + " [Warning] if you notice bad performance, install NodeJS and run \"export EXECJS_RUNTIME=Node\" in your shell"
    end

    Locomotive::Common::Logger.info "\n"
  end
end
install_minifiers() click to toggle source
# File lib/locomotive/steam/initializers/sprockets.rb, line 44
def install_minifiers
  # minify javascripts and stylesheets
  self.js_compressor  = :uglify
  self.css_compressor = :scss
end