lib/susanoo/controllers/assets.rb in susanoo-0.11.1 vs lib/susanoo/controllers/assets.rb in susanoo-0.12.0

- old
+ new

@@ -9,29 +9,41 @@ def call(env) # Environment is a sprockets environment instance environment.call env end - def build(generator, route) - assets = Sprockets::Environment.new - assets.append_path File.join(project_root, + def build(generator, options) + platform = options[:platform] + + Sprockets::Helpers.configure do |config| + config.prefix = "/#{platform}_asset/www/assets" + config.debug = false + config.environment = @environment + end + + @environment.append_path File.join(project_root, 'src/assets/javascripts') - assets.append_path File.join(project_root, - 'src/assets/stylesheets') + @environment.append_path File.join(project_root, + 'src/assets/stylesheets') + @environment.append_path File.join(project_root, + 'src/assets/fonts') + + func = lambda do |path, filename| filename !~ %r~assets~ && !%w[.js .css].include?(File.extname(path)) end precompile = [func, /(?:\/|\\|\A)application\.(css|js)$/] - assets.each_logical_path(*precompile).each {|path| + @environment.each_logical_path(*precompile).each {|path| case File.extname(path) when '.js' dir = 'javascripts' when '.css' dir = 'stylesheets' end - assets[path].write_to "www/assets/#{dir}/#{path}" + @environment[path].write_to "www/assets/#{path}" + #@environment[path].write_to "www/assets/#{dir}/#{path}" } if File.exist? File.join(project_root, 'src/assets/images') generator.say_status 'copy', 'src/assets/images'