sprockets 2.3.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of sprockets might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/LICENSE +2 -2
- data/README.md +332 -115
- data/bin/sprockets +8 -0
- data/lib/rake/sprocketstask.rb +25 -13
- data/lib/sprockets/asset.rb +143 -205
- data/lib/sprockets/autoload/closure.rb +7 -0
- data/lib/sprockets/autoload/coffee_script.rb +7 -0
- data/lib/sprockets/autoload/eco.rb +7 -0
- data/lib/sprockets/autoload/ejs.rb +7 -0
- data/lib/sprockets/autoload/sass.rb +7 -0
- data/lib/sprockets/autoload/uglifier.rb +7 -0
- data/lib/sprockets/autoload/yui.rb +7 -0
- data/lib/sprockets/autoload.rb +11 -0
- data/lib/sprockets/base.rb +49 -257
- data/lib/sprockets/bower.rb +58 -0
- data/lib/sprockets/bundle.rb +65 -0
- data/lib/sprockets/cache/file_store.rb +165 -14
- data/lib/sprockets/cache/memory_store.rb +66 -0
- data/lib/sprockets/cache/null_store.rb +46 -0
- data/lib/sprockets/cache.rb +234 -0
- data/lib/sprockets/cached_environment.rb +69 -0
- data/lib/sprockets/closure_compressor.rb +53 -0
- data/lib/sprockets/coffee_script_processor.rb +25 -0
- data/lib/sprockets/coffee_script_template.rb +6 -0
- data/lib/sprockets/compressing.rb +74 -0
- data/lib/sprockets/configuration.rb +83 -0
- data/lib/sprockets/context.rb +125 -131
- data/lib/sprockets/dependencies.rb +73 -0
- data/lib/sprockets/digest_utils.rb +156 -0
- data/lib/sprockets/directive_processor.rb +209 -211
- data/lib/sprockets/eco_processor.rb +32 -0
- data/lib/sprockets/eco_template.rb +3 -35
- data/lib/sprockets/ejs_processor.rb +31 -0
- data/lib/sprockets/ejs_template.rb +3 -34
- data/lib/sprockets/encoding_utils.rb +258 -0
- data/lib/sprockets/engines.rb +45 -38
- data/lib/sprockets/environment.rb +17 -67
- data/lib/sprockets/erb_processor.rb +30 -0
- data/lib/sprockets/erb_template.rb +6 -0
- data/lib/sprockets/errors.rb +6 -13
- data/lib/sprockets/file_reader.rb +15 -0
- data/lib/sprockets/http_utils.rb +115 -0
- data/lib/sprockets/jst_processor.rb +35 -19
- data/lib/sprockets/legacy.rb +314 -0
- data/lib/sprockets/legacy_proc_processor.rb +35 -0
- data/lib/sprockets/legacy_tilt_processor.rb +29 -0
- data/lib/sprockets/loader.rb +176 -0
- data/lib/sprockets/manifest.rb +179 -98
- data/lib/sprockets/manifest_utils.rb +45 -0
- data/lib/sprockets/mime.rb +114 -32
- data/lib/sprockets/path_dependency_utils.rb +85 -0
- data/lib/sprockets/path_digest_utils.rb +47 -0
- data/lib/sprockets/path_utils.rb +282 -0
- data/lib/sprockets/paths.rb +81 -0
- data/lib/sprockets/processing.rb +157 -189
- data/lib/sprockets/processor_utils.rb +103 -0
- data/lib/sprockets/resolve.rb +208 -0
- data/lib/sprockets/sass_cache_store.rb +19 -15
- data/lib/sprockets/sass_compressor.rb +59 -0
- data/lib/sprockets/sass_functions.rb +2 -0
- data/lib/sprockets/sass_importer.rb +2 -29
- data/lib/sprockets/sass_processor.rb +285 -0
- data/lib/sprockets/sass_template.rb +4 -44
- data/lib/sprockets/server.rb +109 -84
- data/lib/sprockets/transformers.rb +145 -0
- data/lib/sprockets/uglifier_compressor.rb +63 -0
- data/lib/sprockets/uri_utils.rb +190 -0
- data/lib/sprockets/utils.rb +193 -44
- data/lib/sprockets/version.rb +1 -1
- data/lib/sprockets/yui_compressor.rb +65 -0
- data/lib/sprockets.rb +144 -53
- metadata +248 -238
- data/lib/sprockets/asset_attributes.rb +0 -126
- data/lib/sprockets/bundled_asset.rb +0 -79
- data/lib/sprockets/caching.rb +0 -96
- data/lib/sprockets/charset_normalizer.rb +0 -41
- data/lib/sprockets/index.rb +0 -99
- data/lib/sprockets/processed_asset.rb +0 -152
- data/lib/sprockets/processor.rb +0 -32
- data/lib/sprockets/safety_colons.rb +0 -28
- data/lib/sprockets/scss_template.rb +0 -13
- data/lib/sprockets/static_asset.rb +0 -57
- data/lib/sprockets/trail.rb +0 -90
data/lib/sprockets/utils.rb
CHANGED
@@ -1,55 +1,108 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
module Sprockets
|
2
|
-
#
|
4
|
+
# Internal: Utils, we didn't know where else to put it! Functions may
|
5
|
+
# eventually be shuffled into more specific drawers.
|
3
6
|
module Utils
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
7
|
+
extend self
|
8
|
+
|
9
|
+
# Internal: Check if object can safely be .dup'd.
|
10
|
+
#
|
11
|
+
# Similar to ActiveSupport #duplicable? check.
|
12
|
+
#
|
13
|
+
# obj - Any Object
|
14
|
+
#
|
15
|
+
# Returns false if .dup would raise a TypeError, otherwise true.
|
16
|
+
def duplicable?(obj)
|
17
|
+
case obj
|
18
|
+
when NilClass, FalseClass, TrueClass, Symbol, Numeric
|
19
|
+
false
|
20
|
+
else
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Internal: Duplicate and store key/value on new frozen hash.
|
26
|
+
#
|
27
|
+
# Seperated for recursive calls, always use hash_reassoc(hash, *keys).
|
28
|
+
#
|
29
|
+
# hash - Hash
|
30
|
+
# key - Object key
|
31
|
+
#
|
32
|
+
# Returns Hash.
|
33
|
+
def hash_reassoc1(hash, key)
|
34
|
+
hash = hash.dup if hash.frozen?
|
35
|
+
old_value = hash[key]
|
36
|
+
old_value = old_value.dup if duplicable?(old_value)
|
37
|
+
new_value = yield old_value
|
38
|
+
new_value.freeze if duplicable?(new_value)
|
39
|
+
hash.store(key, new_value)
|
40
|
+
hash.freeze
|
41
|
+
end
|
42
|
+
|
43
|
+
# Internal: Duplicate and store key/value on new frozen hash.
|
44
|
+
#
|
45
|
+
# Similar to Hash#store for nested frozen hashes.
|
46
|
+
#
|
47
|
+
# hash - Hash
|
48
|
+
# key - Object keys. Use multiple keys for nested hashes.
|
49
|
+
# block - Receives current value at key.
|
50
|
+
#
|
51
|
+
# Examples
|
52
|
+
#
|
53
|
+
# config = {paths: ["/bin", "/sbin"]}.freeze
|
54
|
+
# new_config = hash_reassoc(config, :paths) do |paths|
|
55
|
+
# paths << "/usr/local/bin"
|
56
|
+
# end
|
57
|
+
#
|
58
|
+
# Returns duplicated frozen Hash.
|
59
|
+
def hash_reassoc(hash, *keys, &block)
|
60
|
+
if keys.size == 1
|
61
|
+
hash_reassoc1(hash, keys[0], &block)
|
62
|
+
else
|
63
|
+
hash_reassoc1(hash, keys[0]) do |value|
|
64
|
+
hash_reassoc(value, *keys[1..-1], &block)
|
27
65
|
end
|
28
66
|
end
|
67
|
+
end
|
29
68
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
"Resave the file as UTF-8 or upgrade to Ruby 1.9."
|
47
|
-
end
|
69
|
+
# Internal: Check if string has a trailing semicolon.
|
70
|
+
#
|
71
|
+
# str - String
|
72
|
+
#
|
73
|
+
# Returns true or false.
|
74
|
+
def string_end_with_semicolon?(str)
|
75
|
+
i = str.size - 1
|
76
|
+
while i >= 0
|
77
|
+
c = str[i]
|
78
|
+
i -= 1
|
79
|
+
if c == "\n" || c == " " || c == "\t"
|
80
|
+
next
|
81
|
+
elsif c != ";"
|
82
|
+
return false
|
83
|
+
else
|
84
|
+
return true
|
48
85
|
end
|
49
86
|
end
|
87
|
+
true
|
50
88
|
end
|
51
89
|
|
52
|
-
#
|
90
|
+
# Internal: Accumulate asset source to buffer and append a trailing
|
91
|
+
# semicolon if necessary.
|
92
|
+
#
|
93
|
+
# buf - String memo
|
94
|
+
# asset - Asset
|
95
|
+
#
|
96
|
+
# Returns appended buffer String.
|
97
|
+
def concat_javascript_sources(buf, source)
|
98
|
+
if string_end_with_semicolon?(buf)
|
99
|
+
buf + source
|
100
|
+
else
|
101
|
+
buf + ";\n" + source
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Internal: Prepends a leading "." to an extension if its missing.
|
53
106
|
#
|
54
107
|
# normalize_extension("js")
|
55
108
|
# # => ".js"
|
@@ -57,7 +110,7 @@ module Sprockets
|
|
57
110
|
# normalize_extension(".css")
|
58
111
|
# # => ".css"
|
59
112
|
#
|
60
|
-
def
|
113
|
+
def normalize_extension(extension)
|
61
114
|
extension = extension.to_s
|
62
115
|
if extension[/^\./]
|
63
116
|
extension
|
@@ -65,5 +118,101 @@ module Sprockets
|
|
65
118
|
".#{extension}"
|
66
119
|
end
|
67
120
|
end
|
121
|
+
|
122
|
+
# Internal: Feature detect if UnboundMethods can #bind to any Object or
|
123
|
+
# just Objects that share the same super class.
|
124
|
+
# Basically if RUBY_VERSION >= 2.
|
125
|
+
UNBOUND_METHODS_BIND_TO_ANY_OBJECT = begin
|
126
|
+
foo = Module.new { def bar; end }
|
127
|
+
foo.instance_method(:bar).bind(Object.new)
|
128
|
+
true
|
129
|
+
rescue TypeError
|
130
|
+
false
|
131
|
+
end
|
132
|
+
|
133
|
+
# Internal: Inject into target module for the duration of the block.
|
134
|
+
#
|
135
|
+
# mod - Module
|
136
|
+
#
|
137
|
+
# Returns result of block.
|
138
|
+
def module_include(base, mod)
|
139
|
+
old_methods = {}
|
140
|
+
|
141
|
+
mod.instance_methods.each do |sym|
|
142
|
+
old_methods[sym] = base.instance_method(sym) if base.method_defined?(sym)
|
143
|
+
end
|
144
|
+
|
145
|
+
unless UNBOUND_METHODS_BIND_TO_ANY_OBJECT
|
146
|
+
base.send(:include, mod) unless base < mod
|
147
|
+
end
|
148
|
+
|
149
|
+
mod.instance_methods.each do |sym|
|
150
|
+
method = mod.instance_method(sym)
|
151
|
+
base.send(:define_method, sym, method)
|
152
|
+
end
|
153
|
+
|
154
|
+
yield
|
155
|
+
ensure
|
156
|
+
mod.instance_methods.each do |sym|
|
157
|
+
base.send(:undef_method, sym) if base.method_defined?(sym)
|
158
|
+
end
|
159
|
+
old_methods.each do |sym, method|
|
160
|
+
base.send(:define_method, sym, method)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Internal: Post-order Depth-First search algorithm.
|
165
|
+
#
|
166
|
+
# Used for resolving asset dependencies.
|
167
|
+
#
|
168
|
+
# initial - Initial Array of nodes to traverse.
|
169
|
+
# block -
|
170
|
+
# node - Current node to get children of
|
171
|
+
#
|
172
|
+
# Returns a Set of nodes.
|
173
|
+
def dfs(initial)
|
174
|
+
nodes, seen = Set.new, Set.new
|
175
|
+
stack = Array(initial).reverse
|
176
|
+
|
177
|
+
while node = stack.pop
|
178
|
+
if seen.include?(node)
|
179
|
+
nodes.add(node)
|
180
|
+
else
|
181
|
+
seen.add(node)
|
182
|
+
stack.push(node)
|
183
|
+
stack.concat(Array(yield node).reverse)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
nodes
|
188
|
+
end
|
189
|
+
|
190
|
+
# Internal: Post-order Depth-First search algorithm that gathers all paths
|
191
|
+
# along the way.
|
192
|
+
#
|
193
|
+
# TODO: Rename function.
|
194
|
+
#
|
195
|
+
# path - Initial Array node path
|
196
|
+
# block -
|
197
|
+
# node - Current node to get children of
|
198
|
+
#
|
199
|
+
# Returns an Array of node Arrays.
|
200
|
+
def dfs_paths(path)
|
201
|
+
paths = []
|
202
|
+
stack, seen = [path], Set.new
|
203
|
+
|
204
|
+
while path = stack.pop
|
205
|
+
if !seen.include?(path.last)
|
206
|
+
seen.add(path.last)
|
207
|
+
paths << path if path.size > 1
|
208
|
+
|
209
|
+
Array(yield path.last).reverse_each do |node|
|
210
|
+
stack.push(path + [node])
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
paths
|
216
|
+
end
|
68
217
|
end
|
69
218
|
end
|
data/lib/sprockets/version.rb
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'sprockets/autoload'
|
2
|
+
|
3
|
+
module Sprockets
|
4
|
+
# Public: YUI compressor.
|
5
|
+
#
|
6
|
+
# To accept the default options
|
7
|
+
#
|
8
|
+
# environment.register_bundle_processor 'application/javascript',
|
9
|
+
# Sprockets::YUICompressor
|
10
|
+
#
|
11
|
+
# Or to pass options to the YUI::JavaScriptCompressor class.
|
12
|
+
#
|
13
|
+
# environment.register_bundle_processor 'application/javascript',
|
14
|
+
# Sprockets::YUICompressor.new(munge: true)
|
15
|
+
#
|
16
|
+
class YUICompressor
|
17
|
+
VERSION = '1'
|
18
|
+
|
19
|
+
# Public: Return singleton instance with default options.
|
20
|
+
#
|
21
|
+
# Returns YUICompressor object.
|
22
|
+
def self.instance
|
23
|
+
@instance ||= new
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.call(input)
|
27
|
+
instance.call(input)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.cache_key
|
31
|
+
instance.cache_key
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_reader :cache_key
|
35
|
+
|
36
|
+
def initialize(options = {})
|
37
|
+
@options = options
|
38
|
+
@cache_key = [
|
39
|
+
self.class.name,
|
40
|
+
Autoload::YUI::Compressor::VERSION,
|
41
|
+
VERSION,
|
42
|
+
options
|
43
|
+
].freeze
|
44
|
+
end
|
45
|
+
|
46
|
+
def call(input)
|
47
|
+
data = input[:data]
|
48
|
+
|
49
|
+
case input[:content_type]
|
50
|
+
when 'application/javascript'
|
51
|
+
key = @cache_key + [input[:content_type], input[:data]]
|
52
|
+
input[:cache].fetch(key) do
|
53
|
+
Autoload::YUI::JavaScriptCompressor.new(@options).compress(data)
|
54
|
+
end
|
55
|
+
when 'text/css'
|
56
|
+
key = @cache_key + [input[:content_type], input[:data]]
|
57
|
+
input[:cache].fetch(key) do
|
58
|
+
Autoload::YUI::CssCompressor.new(@options).compress(data)
|
59
|
+
end
|
60
|
+
else
|
61
|
+
data
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/sprockets.rb
CHANGED
@@ -1,68 +1,159 @@
|
|
1
1
|
require 'sprockets/version'
|
2
|
+
require 'sprockets/cache'
|
3
|
+
require 'sprockets/environment'
|
4
|
+
require 'sprockets/errors'
|
5
|
+
require 'sprockets/manifest'
|
2
6
|
|
3
7
|
module Sprockets
|
4
|
-
|
5
|
-
|
6
|
-
autoload :Engines, "sprockets/engines"
|
7
|
-
autoload :Environment, "sprockets/environment"
|
8
|
-
autoload :Index, "sprockets/index"
|
9
|
-
autoload :Manifest, "sprockets/manifest"
|
10
|
-
|
11
|
-
# Assets
|
12
|
-
autoload :Asset, "sprockets/asset"
|
13
|
-
autoload :BundledAsset, "sprockets/bundled_asset"
|
14
|
-
autoload :ProcessedAsset, "sprockets/processed_asset"
|
15
|
-
autoload :StaticAsset, "sprockets/static_asset"
|
16
|
-
|
17
|
-
# Processing
|
18
|
-
autoload :CharsetNormalizer, "sprockets/charset_normalizer"
|
19
|
-
autoload :Context, "sprockets/context"
|
20
|
-
autoload :DirectiveProcessor, "sprockets/directive_processor"
|
21
|
-
autoload :EcoTemplate, "sprockets/eco_template"
|
22
|
-
autoload :EjsTemplate, "sprockets/ejs_template"
|
23
|
-
autoload :JstProcessor, "sprockets/jst_processor"
|
24
|
-
autoload :Processor, "sprockets/processor"
|
25
|
-
autoload :SafetyColons, "sprockets/safety_colons"
|
26
|
-
autoload :SassCacheStore, "sprockets/sass_cache_store"
|
27
|
-
autoload :SassImporter, "sprockets/sass_importer"
|
28
|
-
autoload :SassTemplate, "sprockets/sass_template"
|
29
|
-
autoload :ScssTemplate, "sprockets/scss_template"
|
30
|
-
|
31
|
-
# Internal utilities
|
32
|
-
autoload :ArgumentError, "sprockets/errors"
|
33
|
-
autoload :AssetAttributes, "sprockets/asset_attributes"
|
34
|
-
autoload :CircularDependencyError, "sprockets/errors"
|
35
|
-
autoload :ContentTypeMismatch, "sprockets/errors"
|
36
|
-
autoload :EngineError, "sprockets/errors"
|
37
|
-
autoload :Error, "sprockets/errors"
|
38
|
-
autoload :FileNotFound, "sprockets/errors"
|
39
|
-
autoload :Utils, "sprockets/utils"
|
40
|
-
|
41
|
-
module Cache
|
42
|
-
autoload :FileStore, "sprockets/cache/file_store"
|
43
|
-
end
|
8
|
+
require 'sprockets/processor_utils'
|
9
|
+
extend ProcessorUtils
|
44
10
|
|
45
11
|
# Extend Sprockets module to provide global registry
|
46
|
-
|
47
|
-
|
12
|
+
require 'sprockets/configuration'
|
13
|
+
require 'sprockets/context'
|
14
|
+
require 'digest/sha2'
|
15
|
+
extend Configuration
|
16
|
+
|
17
|
+
self.config = {
|
18
|
+
bundle_processors: Hash.new { |h, k| [].freeze }.freeze,
|
19
|
+
bundle_reducers: Hash.new { |h, k| {}.freeze }.freeze,
|
20
|
+
compressors: Hash.new { |h, k| {}.freeze }.freeze,
|
21
|
+
dependencies: Set.new.freeze,
|
22
|
+
dependency_resolvers: {}.freeze,
|
23
|
+
digest_class: Digest::SHA256,
|
24
|
+
engine_mime_types: {}.freeze,
|
25
|
+
engines: {}.freeze,
|
26
|
+
mime_exts: {}.freeze,
|
27
|
+
mime_types: {}.freeze,
|
28
|
+
paths: [].freeze,
|
29
|
+
pipelines: {}.freeze,
|
30
|
+
postprocessors: Hash.new { |h, k| [].freeze }.freeze,
|
31
|
+
preprocessors: Hash.new { |h, k| [].freeze }.freeze,
|
32
|
+
registered_transformers: Hash.new { |h, k| {}.freeze }.freeze,
|
33
|
+
root: File.expand_path('..', __FILE__).freeze,
|
34
|
+
transformers: Hash.new { |h, k| {}.freeze }.freeze,
|
35
|
+
version: ""
|
36
|
+
}.freeze
|
37
|
+
self.computed_config = {}
|
38
|
+
|
39
|
+
@context_class = Context
|
40
|
+
|
41
|
+
require 'logger'
|
42
|
+
@logger = Logger.new($stderr)
|
43
|
+
@logger.level = Logger::FATAL
|
44
|
+
|
45
|
+
# Common asset text types
|
46
|
+
register_mime_type 'application/javascript', extensions: ['.js'], charset: :unicode
|
47
|
+
register_mime_type 'application/json', extensions: ['.json'], charset: :unicode
|
48
|
+
register_mime_type 'application/xml', extensions: ['.xml']
|
49
|
+
register_mime_type 'text/css', extensions: ['.css'], charset: :css
|
50
|
+
register_mime_type 'text/html', extensions: ['.html', '.htm'], charset: :html
|
51
|
+
register_mime_type 'text/plain', extensions: ['.txt', '.text']
|
52
|
+
register_mime_type 'text/yaml', extensions: ['.yml', '.yaml'], charset: :unicode
|
53
|
+
|
54
|
+
# Common image types
|
55
|
+
register_mime_type 'image/x-icon', extensions: ['.ico']
|
56
|
+
register_mime_type 'image/bmp', extensions: ['.bmp']
|
57
|
+
register_mime_type 'image/gif', extensions: ['.gif']
|
58
|
+
register_mime_type 'image/webp', extensions: ['.webp']
|
59
|
+
register_mime_type 'image/png', extensions: ['.png']
|
60
|
+
register_mime_type 'image/jpeg', extensions: ['.jpg', '.jpeg']
|
61
|
+
register_mime_type 'image/tiff', extensions: ['.tiff', '.tif']
|
62
|
+
register_mime_type 'image/svg+xml', extensions: ['.svg']
|
63
|
+
|
64
|
+
# Common audio/video types
|
65
|
+
register_mime_type 'video/webm', extensions: ['.webm']
|
66
|
+
register_mime_type 'audio/basic', extensions: ['.snd', '.au']
|
67
|
+
register_mime_type 'audio/aiff', extensions: ['.aiff']
|
68
|
+
register_mime_type 'audio/mpeg', extensions: ['.mp3', '.mp2', '.m2a', '.m3a']
|
69
|
+
register_mime_type 'application/ogg', extensions: ['.ogx']
|
70
|
+
register_mime_type 'audio/midi', extensions: ['.midi', '.mid']
|
71
|
+
register_mime_type 'video/avi', extensions: ['.avi']
|
72
|
+
register_mime_type 'audio/wave', extensions: ['.wav', '.wave']
|
73
|
+
register_mime_type 'video/mp4', extensions: ['.mp4', '.m4v']
|
74
|
+
|
75
|
+
# Common font types
|
76
|
+
register_mime_type 'application/vnd.ms-fontobject', extensions: ['.eot']
|
77
|
+
register_mime_type 'application/x-font-ttf', extensions: ['.ttf']
|
78
|
+
register_mime_type 'application/font-woff', extensions: ['.woff']
|
79
|
+
|
80
|
+
register_pipeline :source do |env|
|
81
|
+
[]
|
82
|
+
end
|
83
|
+
|
84
|
+
register_pipeline :self do |env, type, file_type, engine_extnames|
|
85
|
+
env.self_processors_for(type, file_type, engine_extnames)
|
86
|
+
end
|
48
87
|
|
49
|
-
|
50
|
-
|
88
|
+
register_pipeline :default do |env, type, file_type, engine_extnames|
|
89
|
+
env.default_processors_for(type, file_type, engine_extnames)
|
90
|
+
end
|
91
|
+
|
92
|
+
require 'sprockets/directive_processor'
|
93
|
+
register_preprocessor 'text/css', DirectiveProcessor.new(
|
94
|
+
comments: ["//", ["/*", "*/"]]
|
95
|
+
)
|
96
|
+
register_preprocessor 'application/javascript', DirectiveProcessor.new(
|
97
|
+
comments: ["//", ["/*", "*/"]] + ["#", ["###", "###"]]
|
98
|
+
)
|
99
|
+
|
100
|
+
require 'sprockets/bundle'
|
101
|
+
register_bundle_processor 'application/javascript', Bundle
|
102
|
+
register_bundle_processor 'text/css', Bundle
|
103
|
+
|
104
|
+
register_bundle_metadata_reducer '*/*', :data, :+
|
105
|
+
register_bundle_metadata_reducer 'application/javascript', :data, Utils.method(:concat_javascript_sources)
|
106
|
+
register_bundle_metadata_reducer '*/*', :links, :+
|
107
|
+
|
108
|
+
require 'sprockets/closure_compressor'
|
109
|
+
require 'sprockets/sass_compressor'
|
110
|
+
require 'sprockets/uglifier_compressor'
|
111
|
+
require 'sprockets/yui_compressor'
|
112
|
+
register_compressor 'text/css', :sass, SassCompressor
|
113
|
+
register_compressor 'text/css', :scss, SassCompressor
|
114
|
+
register_compressor 'text/css', :yui, YUICompressor
|
115
|
+
register_compressor 'application/javascript', :closure, ClosureCompressor
|
116
|
+
register_compressor 'application/javascript', :uglifier, UglifierCompressor
|
117
|
+
register_compressor 'application/javascript', :uglify, UglifierCompressor
|
118
|
+
register_compressor 'application/javascript', :yui, YUICompressor
|
51
119
|
|
52
120
|
# Mmm, CoffeeScript
|
53
|
-
|
121
|
+
require 'sprockets/coffee_script_processor'
|
122
|
+
register_engine '.coffee', CoffeeScriptProcessor, mime_type: 'application/javascript'
|
54
123
|
|
55
124
|
# JST engines
|
56
|
-
|
57
|
-
|
58
|
-
|
125
|
+
require 'sprockets/eco_processor'
|
126
|
+
require 'sprockets/ejs_processor'
|
127
|
+
require 'sprockets/jst_processor'
|
128
|
+
register_engine '.jst', JstProcessor, mime_type: 'application/javascript'
|
129
|
+
register_engine '.eco', EcoProcessor, mime_type: 'application/javascript'
|
130
|
+
register_engine '.ejs', EjsProcessor, mime_type: 'application/javascript'
|
59
131
|
|
60
132
|
# CSS engines
|
61
|
-
|
62
|
-
register_engine '.sass',
|
63
|
-
register_engine '.scss',
|
133
|
+
require 'sprockets/sass_processor'
|
134
|
+
register_engine '.sass', SassProcessor, mime_type: 'text/css'
|
135
|
+
register_engine '.scss', ScssProcessor, mime_type: 'text/css'
|
136
|
+
register_bundle_metadata_reducer 'text/css', :sass_dependencies, Set.new, :+
|
64
137
|
|
65
138
|
# Other
|
66
|
-
|
67
|
-
register_engine '.
|
139
|
+
require 'sprockets/erb_processor'
|
140
|
+
register_engine '.erb', ERBProcessor, mime_type: 'text/plain'
|
141
|
+
|
142
|
+
register_dependency_resolver 'environment-version' do |env|
|
143
|
+
env.version
|
144
|
+
end
|
145
|
+
register_dependency_resolver 'environment-paths' do |env|
|
146
|
+
env.paths
|
147
|
+
end
|
148
|
+
register_dependency_resolver 'file-digest' do |env, str|
|
149
|
+
env.file_digest(env.parse_file_digest_uri(str))
|
150
|
+
end
|
151
|
+
register_dependency_resolver 'processors' do |env, str|
|
152
|
+
env.resolve_processors_cache_key_uri(str)
|
153
|
+
end
|
154
|
+
|
155
|
+
depend_on 'environment-version'
|
156
|
+
depend_on 'environment-paths'
|
68
157
|
end
|
158
|
+
|
159
|
+
require 'sprockets/legacy'
|