Module: Roda::RodaPlugins::SprocketAssets
- Defined in:
- lib/roda/plugins/sprocket_assets.rb,
lib/roda/plugins/sprocket_assets_task.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods, RequestClassMethods, RequestMethods
Classes: Task
Constant Summary
collapse
- DEFAULTS =
{
sprockets: Sprockets::Environment.new,
precompile: %w(app.js app.css *.png *.jpg *.svg *.eot *.ttf *.woff *.woff2),
prefix: %w(assets vendor/assets),
root: false,
public_path: false,
path_prefix: nil,
protocol: :http,
css_compressor: nil,
js_compressor: nil,
host: nil,
digest: true,
opal: false,
debug: false
}.freeze
Class Method Summary
collapse
Class Method Details
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# 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|
paths = if Pathname.new(prefix).absolute?
Dir[File.join(prefix, '*')]
else
Dir[File.join(opts[:root], prefix, '*')]
end
paths.each { |path| opts[:sprockets].append_path path }
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) ⇒ Object
24
25
26
|
# File 'lib/roda/plugins/sprocket_assets.rb', line 24
def self.load_dependencies(app, _opts = nil)
app.plugin :environments
end
|