Module: Roda::RodaPlugins::Sprockets
- Defined in:
- lib/roda/plugins/sprockets.rb,
lib/roda/plugins/sprockets_task.rb
Defined Under Namespace
Modules: ClassMethods, InstanceMethods, RequestMethods
Classes: Task
Constant Summary
collapse
- DEFAULTS =
{
sprockets: nil,
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: "/assets",
protocol: :http,
css_compressor: nil,
js_compressor: nil,
host: nil,
digest: true,
opal: false,
debug: false,
cache: nil,
}.freeze
Class Method Summary
collapse
Class Method Details
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/roda/plugins/sprockets.rb', line 29
def self.configure(app, plugin_options = {})
if app.opts[:sprockets]
app.opts[:sprockets].merge!(plugin_options)
else
app.opts[:sprockets] = plugin_options.dup
end
options = app.opts[:sprockets].merge! plugin_options
DEFAULTS.each { |k, v| options[k] = v unless options.key?(k) }
options[:root] = app.opts[:root] if !options[:root]
i(root public_path).each { |type| raise "#{type} needs to be set." unless options[type] }
require 'opal/sprockets' if options[:opal]
options[:sprockets] ||= ::Sprockets::Environment.new
options[:prefix].each do |prefix|
if prefix.end_with? '/'
paths = if Pathname.new(prefix).absolute?
Dir[File.join(prefix)]
else
Dir[File.join(options[:root], prefix)]
end
else
paths = if Pathname.new(prefix).absolute?
Dir[File.join(prefix, '*')]
else
Dir[File.join(options[:root], prefix, '*')]
end
end
paths.each do |path|
options[:sprockets].append_path path
end
end
if options[:opal]
Opal.paths.each do |path|
options[:sprockets].append_path path
end
end
if options[:cache]
options[:sprockets].cache = options[:cache]
end
options[:sprockets_helpers] = ::Sprockets::Helpers::Settings.new
options[:sprockets_helpers].environment = options[:sprockets]
options[:sprockets_helpers].digest = options[:digest]
options[:sprockets_helpers].prefix = options[:path_prefix] unless options[:path_prefix].nil?
options[:sprockets_helpers].debug = options[:debug]
app.configure :staging, :production do
options[:sprockets].css_compressor = options[:css_compressor] unless options[:css_compressor].nil?
options[:sprockets].js_compressor = options[:js_compressor] unless options[:js_compressor].nil?
options[:sprockets_helpers].manifest = ::Sprockets::Manifest.new(options[:sprockets], options[:public_path])
options[:sprockets_helpers].protocol = options[:protocol]
options[:sprockets_helpers].asset_host = options[:host] unless options[:host].nil?
end
end
|
.load_dependencies(app, _opts = nil) ⇒ Object
25
26
27
|
# File 'lib/roda/plugins/sprockets.rb', line 25
def self.load_dependencies(app, _opts = nil)
app.plugin :environments
end
|