Module: Locomotive::Mounter::Extensions::Sprockets
- Defined in:
- lib/locomotive/mounter/extensions/sprockets.rb
Constant Summary collapse
- @@env =
@@path = nil
Class Method Summary collapse
-
.environment(site_path, minify = false) ⇒ Object
Build a Sprocket environment for the current site.
- .is_java_installed? ⇒ Boolean
Class Method Details
.environment(site_path, minify = false) ⇒ Object
Build a Sprocket environment for the current site. This method returns an unique environment for each call unless the site_path changed.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/locomotive/mounter/extensions/sprockets.rb', line 18 def self.environment(site_path, minify = false) return @@env if @@env && @@path == site_path @@path = site_path @@env = ::Sprockets::Environment.new.tap do |env| if minify && is_java_installed? # minify javascripts and stylesheets env.js_compressor = YUI::JavaScriptCompressor.new env.css_compressor = YUI::CssCompressor.new else = "[Important] YUICompressor requires java to be installed. The JAVA_HOME variable should also be set.\n" Locomotive::Mounter.logger.warn .colorize(color: :red) end %w(fonts stylesheets javascripts).each do |name| env.append_path File.join(site_path, 'public', name) end end end |
.is_java_installed? ⇒ Boolean
38 39 40 |
# File 'lib/locomotive/mounter/extensions/sprockets.rb', line 38 def self.is_java_installed? `which java` != '' && (!ENV['JAVA_HOME'].blank? && File.exists?(ENV['JAVA_HOME'])) end |