add autoprefixer support (issue locomotivecms/wagon#110) + do not instantiate a new sprocket env for each request

did committed Jan 04, 2016
commit 526d8397f1afa2fdadf534c18c20972e914eb262
Showing 4 changed files with 23 additions and 2 deletions
Gemfile.lock +5 -1
@@ @@ -3,6 +3,7 @@ PATH
specs:
locomotivecms_steam (1.0.0.rc9)
RedCloth (~> 4.2.9)
+ autoprefixer-rails (~> 6.2.3)
chronic (~> 0.10.2)
coffee-script (~> 2.4.1)
compass (~> 1.0.3)
@@ @@ -40,6 +41,9 @@ GEM
tzinfo (~> 1.1)
addressable (2.4.0)
attr_extras (4.4.0)
+ autoprefixer-rails (6.2.3)
+ execjs
+ json
bson (4.0.0)
byebug (8.2.1)
chronic (0.10.2)
@@ @@ -156,7 +160,7 @@ GEM
rake (10.4.2)
rake-compiler (0.9.5)
rake
- rb-fsevent (0.9.6)
+ rb-fsevent (0.9.7)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
ref (2.0.0)
locomotive/steam/initializers/sprockets.rb b/lib/locomotive/steam/initializers/sprockets.rb +10 -0
@@ @@ -3,6 +3,7 @@ require 'sass'
require 'less'
require 'coffee_script'
require 'compass'
+ require 'autoprefixer-rails'
module Locomotive::Steam
@@ @@ -16,6 +17,8 @@ module Locomotive::Steam
append_steam_paths
install_yui_compressor(options)
+
+ install_autoprefixer
end
private
@@ @@ -44,6 +47,13 @@ module Locomotive::Steam
end
end
+ def install_autoprefixer
+ file = File.join(root, '..', 'config', 'autoprefixer.yml')
+ params = (File.exist?(file) ? ::YAML.load_file(file) : {}).symbolize_keys
+
+ AutoprefixerRails.install(self, params)
+ end
+
def is_java_installed?
`which java` != '' && (!ENV['JAVA_HOME'].blank? && File.exists?(ENV['JAVA_HOME']))
end
locomotive/steam/middlewares/dynamic_assets.rb b/lib/locomotive/steam/middlewares/dynamic_assets.rb +7 -1
@@ @@ -5,11 +5,13 @@ module Locomotive::Steam
REGEXP = /^\/(javascripts|stylesheets)\/(.*)$/o
+ @@sprocket_environments = {}
+
attr_reader :app, :assets
def initialize(app, options)
@app = app
- @assets = Locomotive::Steam::SprocketsEnvironment.new(options[:root], options)
+ @assets = self.class.sprocket_environment(options[:root], options)
end
def call(env)
@@ @@ -21,6 +23,10 @@ module Locomotive::Steam
end
end
+ def self.sprocket_environment(root, options)
+ @@sprocket_environments[root] ||= Locomotive::Steam::SprocketsEnvironment.new(root, options)
+ end
+
end
end
locomotivecms_steam.gemspec +1 -0
@@ @@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'therubyracer', '~> 0.12.2'
spec.add_dependency 'coffee-script', '~> 2.4.1'
spec.add_dependency 'compass', '~> 1.0.3'
+ spec.add_dependency 'autoprefixer-rails', '~> 6.2.3'
spec.add_dependency 'kramdown', '~> 1.9.0'
spec.add_dependency 'RedCloth', '~> 4.2.9'