module Roda::RodaPlugins::SprocketAssets
Constants
- DEFAULTS
Public Class Methods
configure(app, plugin_opts = {})
click to toggle source
# File lib/roda/plugins/sprocket_assets.rb, line 28 def self.configure(app, plugin_opts = {}) app.opts[:sprocket_assets] ? app.opts[:sprocket_assets].merge!(plugin_opts) : app.opts[:sprocket_assets] = plugin_opts.dup opts = app.opts[:sprocket_assets].merge! plugin_opts DEFAULTS.each { |k, v| opts[k] = v unless opts.key?(k) } %i(root public_path).each { |type| raise "#{type} needs to be set." unless opts[type] } opts[:prefix].each do |prefix| # Support absolute asset paths # https://github.com/kalasjocke/sinatra-asset-pipeline/pull/54 if prefix[-1,1] == '/' paths = if Pathname.new(prefix).absolute? Dir[File.join(prefix)] else Dir[File.join(opts[:root], prefix)] end else paths = if Pathname.new(prefix).absolute? Dir[File.join(prefix, '*')] else Dir[File.join(opts[:root], prefix, '*')] end end paths.each do |path| opts[:sprockets].append_path path end end if opts[:opal] require 'opal/sprockets/server' require 'opal/sprockets/processor' require 'roda/plugins/sprockets_cache_key_fix' Opal.paths.each do |path| opts[:sprockets].append_path path end end Sprockets::Helpers.configure do |config| config.environment = opts[:sprockets] config.digest = opts[:digest] config.prefix = opts[:path_prefix] unless opts[:path_prefix].nil? config.debug = opts[:debug] end app.configure :staging, :production do opts[:sprockets].css_compressor = opts[:css_compressor] unless opts[:css_compressor].nil? opts[:sprockets].js_compressor = opts[:js_compressor] unless opts[:js_compressor].nil? Sprockets::Helpers.configure do |config| config.manifest = Sprockets::Manifest.new(opts[:sprockets], opts[:public_path]) config.prefix = opts[:path_prefix] unless opts[:path_prefix].nil? config.protocol = opts[:protocol] config.asset_host = opts[:host] unless opts[:host].nil? end end end
load_dependencies(app, _opts = nil)
click to toggle source
# File lib/roda/plugins/sprocket_assets.rb, line 24 def self.load_dependencies(app, _opts = nil) app.plugin :environments end