sprockets 2.11.3 → 3.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +296 -0
  3. data/LICENSE +2 -2
  4. data/README.md +235 -242
  5. data/bin/sprockets +1 -0
  6. data/lib/rake/sprocketstask.rb +5 -4
  7. data/lib/sprockets/asset.rb +143 -210
  8. data/lib/sprockets/autoload/closure.rb +7 -0
  9. data/lib/sprockets/autoload/coffee_script.rb +7 -0
  10. data/lib/sprockets/autoload/eco.rb +7 -0
  11. data/lib/sprockets/autoload/ejs.rb +7 -0
  12. data/lib/sprockets/autoload/sass.rb +7 -0
  13. data/lib/sprockets/autoload/uglifier.rb +7 -0
  14. data/lib/sprockets/autoload/yui.rb +7 -0
  15. data/lib/sprockets/autoload.rb +11 -0
  16. data/lib/sprockets/base.rb +56 -393
  17. data/lib/sprockets/bower.rb +58 -0
  18. data/lib/sprockets/bundle.rb +69 -0
  19. data/lib/sprockets/cache/file_store.rb +168 -14
  20. data/lib/sprockets/cache/memory_store.rb +66 -0
  21. data/lib/sprockets/cache/null_store.rb +46 -0
  22. data/lib/sprockets/cache.rb +236 -0
  23. data/lib/sprockets/cached_environment.rb +69 -0
  24. data/lib/sprockets/closure_compressor.rb +35 -10
  25. data/lib/sprockets/coffee_script_processor.rb +25 -0
  26. data/lib/sprockets/coffee_script_template.rb +17 -0
  27. data/lib/sprockets/compressing.rb +44 -23
  28. data/lib/sprockets/configuration.rb +83 -0
  29. data/lib/sprockets/context.rb +86 -144
  30. data/lib/sprockets/dependencies.rb +73 -0
  31. data/lib/sprockets/deprecation.rb +90 -0
  32. data/lib/sprockets/digest_utils.rb +180 -0
  33. data/lib/sprockets/directive_processor.rb +207 -211
  34. data/lib/sprockets/eco_processor.rb +32 -0
  35. data/lib/sprockets/eco_template.rb +9 -30
  36. data/lib/sprockets/ejs_processor.rb +31 -0
  37. data/lib/sprockets/ejs_template.rb +9 -29
  38. data/lib/sprockets/encoding_utils.rb +261 -0
  39. data/lib/sprockets/engines.rb +53 -35
  40. data/lib/sprockets/environment.rb +17 -64
  41. data/lib/sprockets/erb_processor.rb +30 -0
  42. data/lib/sprockets/erb_template.rb +11 -0
  43. data/lib/sprockets/errors.rb +4 -13
  44. data/lib/sprockets/file_reader.rb +15 -0
  45. data/lib/sprockets/http_utils.rb +117 -0
  46. data/lib/sprockets/jst_processor.rb +35 -15
  47. data/lib/sprockets/legacy.rb +330 -0
  48. data/lib/sprockets/legacy_proc_processor.rb +35 -0
  49. data/lib/sprockets/legacy_tilt_processor.rb +29 -0
  50. data/lib/sprockets/loader.rb +325 -0
  51. data/lib/sprockets/manifest.rb +202 -127
  52. data/lib/sprockets/manifest_utils.rb +45 -0
  53. data/lib/sprockets/mime.rb +112 -31
  54. data/lib/sprockets/path_dependency_utils.rb +85 -0
  55. data/lib/sprockets/path_digest_utils.rb +47 -0
  56. data/lib/sprockets/path_utils.rb +287 -0
  57. data/lib/sprockets/paths.rb +42 -19
  58. data/lib/sprockets/processing.rb +178 -126
  59. data/lib/sprockets/processor_utils.rb +180 -0
  60. data/lib/sprockets/resolve.rb +211 -0
  61. data/lib/sprockets/sass_cache_store.rb +22 -17
  62. data/lib/sprockets/sass_compressor.rb +39 -15
  63. data/lib/sprockets/sass_functions.rb +2 -70
  64. data/lib/sprockets/sass_importer.rb +2 -29
  65. data/lib/sprockets/sass_processor.rb +292 -0
  66. data/lib/sprockets/sass_template.rb +12 -53
  67. data/lib/sprockets/server.rb +129 -84
  68. data/lib/sprockets/transformers.rb +145 -0
  69. data/lib/sprockets/uglifier_compressor.rb +39 -12
  70. data/lib/sprockets/unloaded_asset.rb +137 -0
  71. data/lib/sprockets/uri_tar.rb +98 -0
  72. data/lib/sprockets/uri_utils.rb +188 -0
  73. data/lib/sprockets/utils/gzip.rb +67 -0
  74. data/lib/sprockets/utils.rb +210 -44
  75. data/lib/sprockets/version.rb +1 -1
  76. data/lib/sprockets/yui_compressor.rb +39 -11
  77. data/lib/sprockets.rb +142 -81
  78. metadata +100 -80
  79. data/lib/sprockets/asset_attributes.rb +0 -137
  80. data/lib/sprockets/bundled_asset.rb +0 -78
  81. data/lib/sprockets/caching.rb +0 -96
  82. data/lib/sprockets/charset_normalizer.rb +0 -41
  83. data/lib/sprockets/index.rb +0 -100
  84. data/lib/sprockets/processed_asset.rb +0 -152
  85. data/lib/sprockets/processor.rb +0 -32
  86. data/lib/sprockets/safety_colons.rb +0 -28
  87. data/lib/sprockets/scss_template.rb +0 -13
  88. data/lib/sprockets/static_asset.rb +0 -58
@@ -1,55 +1,125 @@
1
+ require 'set'
2
+
1
3
  module Sprockets
2
- # `Utils`, we didn't know where else to put it!
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
- # If theres encoding support (aka Ruby 1.9)
5
- if "".respond_to?(:valid_encoding?)
6
- # Define UTF-8 BOM pattern matcher.
7
- # Avoid using a Regexp literal because it inheirts the files
8
- # encoding and we want to avoid syntax errors in other interpreters.
9
- UTF8_BOM_PATTERN = Regexp.new("\\A\uFEFF".encode('utf-8'))
10
-
11
- def self.read_unicode(pathname, external_encoding = Encoding.default_external)
12
- pathname.open("r:#{external_encoding}") do |f|
13
- f.read.tap do |data|
14
- # Eager validate the file's encoding. In most cases we
15
- # expect it to be UTF-8 unless `default_external` is set to
16
- # something else. An error is usually raised if the file is
17
- # saved as UTF-16 when we expected UTF-8.
18
- if !data.valid_encoding?
19
- raise EncodingError, "#{pathname} has a invalid " +
20
- "#{data.encoding} byte sequence"
21
-
22
- # If the file is UTF-8 and theres a BOM, strip it for safe concatenation.
23
- elsif data.encoding.name == "UTF-8" && data =~ UTF8_BOM_PATTERN
24
- data.sub!(UTF8_BOM_PATTERN, "")
25
- end
26
- end
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
+ if RUBY_VERSION >= "2.4.0"
18
+ true
19
+ else
20
+ case obj
21
+ when NilClass, FalseClass, TrueClass, Symbol, Numeric
22
+ false
23
+ else
24
+ true
27
25
  end
28
26
  end
27
+ end
29
28
 
30
- else
31
- # Define UTF-8 and UTF-16 BOM pattern matchers.
32
- # Avoid using a Regexp literal to prevent syntax errors in other interpreters.
33
- UTF8_BOM_PATTERN = Regexp.new("\\A\\xEF\\xBB\\xBF")
34
- UTF16_BOM_PATTERN = Regexp.new("\\A(\\xFE\\xFF|\\xFF\\xFE)")
35
-
36
- def self.read_unicode(pathname)
37
- pathname.read.tap do |data|
38
- # If the file is UTF-8 and theres a BOM, strip it for safe concatenation.
39
- if data =~ UTF8_BOM_PATTERN
40
- data.sub!(UTF8_BOM_PATTERN, "")
41
-
42
- # If we find a UTF-16 BOM, theres nothing we can do on
43
- # 1.8. Only UTF-8 is supported.
44
- elsif data =~ UTF16_BOM_PATTERN
45
- raise EncodingError, "#{pathname} has a UTF-16 BOM. " +
46
- "Resave the file as UTF-8 or upgrade to Ruby 1.9."
47
- end
29
+ # Internal: Duplicate and store key/value on new frozen hash.
30
+ #
31
+ # Seperated for recursive calls, always use hash_reassoc(hash, *keys).
32
+ #
33
+ # hash - Hash
34
+ # key - Object key
35
+ #
36
+ # Returns Hash.
37
+ def hash_reassoc1(hash, key)
38
+ hash = hash.dup if hash.frozen?
39
+ old_value = hash[key]
40
+ old_value = old_value.dup if duplicable?(old_value)
41
+ new_value = yield old_value
42
+ new_value.freeze if duplicable?(new_value)
43
+ hash.store(key, new_value)
44
+ hash.freeze
45
+ end
46
+
47
+ # Internal: Duplicate and store key/value on new frozen hash.
48
+ #
49
+ # Similar to Hash#store for nested frozen hashes.
50
+ #
51
+ # hash - Hash
52
+ # key - Object keys. Use multiple keys for nested hashes.
53
+ # block - Receives current value at key.
54
+ #
55
+ # Examples
56
+ #
57
+ # config = {paths: ["/bin", "/sbin"]}.freeze
58
+ # new_config = hash_reassoc(config, :paths) do |paths|
59
+ # paths << "/usr/local/bin"
60
+ # end
61
+ #
62
+ # Returns duplicated frozen Hash.
63
+ def hash_reassoc(hash, *keys, &block)
64
+ if keys.size == 1
65
+ hash_reassoc1(hash, keys[0], &block)
66
+ else
67
+ hash_reassoc1(hash, keys[0]) do |value|
68
+ hash_reassoc(value, *keys[1..-1], &block)
69
+ end
70
+ end
71
+ end
72
+
73
+ # Internal: Check if string has a trailing semicolon.
74
+ #
75
+ # str - String
76
+ #
77
+ # Returns true or false.
78
+ def string_end_with_semicolon?(str)
79
+ i = str.size - 1
80
+ while i >= 0
81
+ c = str[i].ord
82
+ i -= 1
83
+
84
+ # Need to compare against the ordinals because the string can be UTF_8 or UTF_32LE encoded
85
+ # 0x0A == "\n"
86
+ # 0x20 == " "
87
+ # 0x09 == "\t"
88
+ # 0x3B == ";"
89
+ unless c == 0x0A || c == 0x20 || c == 0x09
90
+ return c === 0x3B
91
+ end
92
+ end
93
+
94
+ true
95
+ end
96
+
97
+ # Internal: Accumulate asset source to buffer and append a trailing
98
+ # semicolon if necessary.
99
+ #
100
+ # buf - String buffer to append to
101
+ # source - String source to append
102
+ #
103
+ # Returns buf String.
104
+ def concat_javascript_sources(buf, source)
105
+ if source.bytesize > 0
106
+ buf << source
107
+
108
+ # If the source contains non-ASCII characters, indexing on it becomes O(N).
109
+ # This will lead to O(N^2) performance in string_end_with_semicolon?, so we should use 32 bit encoding to make sure indexing stays O(1)
110
+ source = source.encode(Encoding::UTF_32LE) unless source.ascii_only?
111
+
112
+ if !string_end_with_semicolon?(source)
113
+ buf << ";\n"
114
+ elsif source[source.size - 1].ord != 0x0A
115
+ buf << "\n"
48
116
  end
49
117
  end
118
+
119
+ buf
50
120
  end
51
121
 
52
- # Prepends a leading "." to an extension if its missing.
122
+ # Internal: Prepends a leading "." to an extension if its missing.
53
123
  #
54
124
  # normalize_extension("js")
55
125
  # # => ".js"
@@ -57,7 +127,7 @@ module Sprockets
57
127
  # normalize_extension(".css")
58
128
  # # => ".css"
59
129
  #
60
- def self.normalize_extension(extension)
130
+ def normalize_extension(extension)
61
131
  extension = extension.to_s
62
132
  if extension[/^\./]
63
133
  extension
@@ -65,5 +135,101 @@ module Sprockets
65
135
  ".#{extension}"
66
136
  end
67
137
  end
138
+
139
+ # Internal: Feature detect if UnboundMethods can #bind to any Object or
140
+ # just Objects that share the same super class.
141
+ # Basically if RUBY_VERSION >= 2.
142
+ UNBOUND_METHODS_BIND_TO_ANY_OBJECT = begin
143
+ foo = Module.new { def bar; end }
144
+ foo.instance_method(:bar).bind(Object.new)
145
+ true
146
+ rescue TypeError
147
+ false
148
+ end
149
+
150
+ # Internal: Inject into target module for the duration of the block.
151
+ #
152
+ # mod - Module
153
+ #
154
+ # Returns result of block.
155
+ def module_include(base, mod)
156
+ old_methods = {}
157
+
158
+ mod.instance_methods.each do |sym|
159
+ old_methods[sym] = base.instance_method(sym) if base.method_defined?(sym)
160
+ end
161
+
162
+ unless UNBOUND_METHODS_BIND_TO_ANY_OBJECT
163
+ base.send(:include, mod) unless base < mod
164
+ end
165
+
166
+ mod.instance_methods.each do |sym|
167
+ method = mod.instance_method(sym)
168
+ base.send(:define_method, sym, method)
169
+ end
170
+
171
+ yield
172
+ ensure
173
+ mod.instance_methods.each do |sym|
174
+ base.send(:undef_method, sym) if base.method_defined?(sym)
175
+ end
176
+ old_methods.each do |sym, method|
177
+ base.send(:define_method, sym, method)
178
+ end
179
+ end
180
+
181
+ # Internal: Post-order Depth-First search algorithm.
182
+ #
183
+ # Used for resolving asset dependencies.
184
+ #
185
+ # initial - Initial Array of nodes to traverse.
186
+ # block -
187
+ # node - Current node to get children of
188
+ #
189
+ # Returns a Set of nodes.
190
+ def dfs(initial)
191
+ nodes, seen = Set.new, Set.new
192
+ stack = Array(initial).reverse
193
+
194
+ while node = stack.pop
195
+ if seen.include?(node)
196
+ nodes.add(node)
197
+ else
198
+ seen.add(node)
199
+ stack.push(node)
200
+ stack.concat(Array(yield node).reverse)
201
+ end
202
+ end
203
+
204
+ nodes
205
+ end
206
+
207
+ # Internal: Post-order Depth-First search algorithm that gathers all paths
208
+ # along the way.
209
+ #
210
+ # TODO: Rename function.
211
+ #
212
+ # path - Initial Array node path
213
+ # block -
214
+ # node - Current node to get children of
215
+ #
216
+ # Returns an Array of node Arrays.
217
+ def dfs_paths(path)
218
+ paths = []
219
+ stack, seen = [path], Set.new
220
+
221
+ while path = stack.pop
222
+ if !seen.include?(path.last)
223
+ seen.add(path.last)
224
+ paths << path if path.size > 1
225
+
226
+ Array(yield path.last).reverse_each do |node|
227
+ stack.push(path + [node])
228
+ end
229
+ end
230
+ end
231
+
232
+ paths
233
+ end
68
234
  end
69
235
  end
@@ -1,3 +1,3 @@
1
1
  module Sprockets
2
- VERSION = "2.11.3"
2
+ VERSION = "3.7.2"
3
3
  end
@@ -1,24 +1,52 @@
1
- require 'tilt'
1
+ require 'sprockets/autoload'
2
+ require 'sprockets/digest_utils'
2
3
 
3
4
  module Sprockets
4
- class YUICompressor < Tilt::Template
5
- def self.engine_initialized?
6
- defined?(::YUI)
5
+ # Public: YUI compressor.
6
+ #
7
+ # To accept the default options
8
+ #
9
+ # environment.register_bundle_processor 'application/javascript',
10
+ # Sprockets::YUICompressor
11
+ #
12
+ # Or to pass options to the YUI::JavaScriptCompressor class.
13
+ #
14
+ # environment.register_bundle_processor 'application/javascript',
15
+ # Sprockets::YUICompressor.new(munge: true)
16
+ #
17
+ class YUICompressor
18
+ VERSION = '1'
19
+
20
+ # Public: Return singleton instance with default options.
21
+ #
22
+ # Returns YUICompressor object.
23
+ def self.instance
24
+ @instance ||= new
7
25
  end
8
26
 
9
- def initialize_engine
10
- require_template_library 'yui/compressor'
27
+ def self.call(input)
28
+ instance.call(input)
11
29
  end
12
30
 
13
- def prepare
31
+ def self.cache_key
32
+ instance.cache_key
14
33
  end
15
34
 
16
- def evaluate(context, locals, &block)
17
- case context.content_type
35
+ attr_reader :cache_key
36
+
37
+ def initialize(options = {})
38
+ @options = options
39
+ @cache_key = "#{self.class.name}:#{Autoload::YUI::Compressor::VERSION}:#{VERSION}:#{DigestUtils.digest(options)}".freeze
40
+ end
41
+
42
+ def call(input)
43
+ data = input[:data]
44
+
45
+ case input[:content_type]
18
46
  when 'application/javascript'
19
- YUI::JavaScriptCompressor.new.compress(data)
47
+ Autoload::YUI::JavaScriptCompressor.new(@options).compress(data)
20
48
  when 'text/css'
21
- YUI::CssCompressor.new.compress(data)
49
+ Autoload::YUI::CssCompressor.new(@options).compress(data)
22
50
  else
23
51
  data
24
52
  end
data/lib/sprockets.rb CHANGED
@@ -1,108 +1,169 @@
1
+ # encoding: utf-8
1
2
  require 'sprockets/version'
3
+ require 'sprockets/cache'
4
+ require 'sprockets/environment'
5
+ require 'sprockets/errors'
6
+ require 'sprockets/manifest'
7
+ require 'sprockets/deprecation'
2
8
 
3
9
  module Sprockets
4
- # Environment
5
- autoload :Base, "sprockets/base"
6
- autoload :Environment, "sprockets/environment"
7
- autoload :Index, "sprockets/index"
8
- autoload :Manifest, "sprockets/manifest"
9
-
10
- # Assets
11
- autoload :Asset, "sprockets/asset"
12
- autoload :BundledAsset, "sprockets/bundled_asset"
13
- autoload :ProcessedAsset, "sprockets/processed_asset"
14
- autoload :StaticAsset, "sprockets/static_asset"
15
-
16
- # Processing
17
- autoload :Context, "sprockets/context"
18
- autoload :EcoTemplate, "sprockets/eco_template"
19
- autoload :EjsTemplate, "sprockets/ejs_template"
20
- autoload :JstProcessor, "sprockets/jst_processor"
21
- autoload :Processor, "sprockets/processor"
22
- autoload :SassCacheStore, "sprockets/sass_cache_store"
23
- autoload :SassFunctions, "sprockets/sass_functions"
24
- autoload :SassImporter, "sprockets/sass_importer"
25
- autoload :SassTemplate, "sprockets/sass_template"
26
- autoload :ScssTemplate, "sprockets/scss_template"
27
-
28
- # Internal utilities
29
- autoload :ArgumentError, "sprockets/errors"
30
- autoload :AssetAttributes, "sprockets/asset_attributes"
31
- autoload :CircularDependencyError, "sprockets/errors"
32
- autoload :ContentTypeMismatch, "sprockets/errors"
33
- autoload :EngineError, "sprockets/errors"
34
- autoload :Error, "sprockets/errors"
35
- autoload :FileNotFound, "sprockets/errors"
36
- autoload :Utils, "sprockets/utils"
37
-
38
- module Cache
39
- autoload :FileStore, "sprockets/cache/file_store"
40
- end
10
+ require 'sprockets/processor_utils'
11
+ extend ProcessorUtils
41
12
 
42
13
  # Extend Sprockets module to provide global registry
43
- require 'hike'
44
- require 'sprockets/engines'
45
- require 'sprockets/mime'
46
- require 'sprockets/processing'
47
- require 'sprockets/compressing'
48
- require 'sprockets/paths'
49
- extend Engines, Mime, Processing, Compressing, Paths
50
-
51
- @trail = Hike::Trail.new(File.expand_path('..', __FILE__))
52
- @mime_types = {}
53
- @engines = {}
54
- @preprocessors = Hash.new { |h, k| h[k] = [] }
55
- @postprocessors = Hash.new { |h, k| h[k] = [] }
56
- @bundle_processors = Hash.new { |h, k| h[k] = [] }
57
- @compressors = Hash.new { |h, k| h[k] = {} }
58
-
59
- register_mime_type 'text/css', '.css'
60
- register_mime_type 'application/javascript', '.js'
14
+ require 'sprockets/configuration'
15
+ require 'sprockets/context'
16
+ require 'digest/sha2'
17
+ extend Configuration
18
+
19
+ self.config = {
20
+ bundle_processors: Hash.new { |h, k| [].freeze }.freeze,
21
+ bundle_reducers: Hash.new { |h, k| {}.freeze }.freeze,
22
+ compressors: Hash.new { |h, k| {}.freeze }.freeze,
23
+ dependencies: Set.new.freeze,
24
+ dependency_resolvers: {}.freeze,
25
+ digest_class: Digest::SHA256,
26
+ engine_mime_types: {}.freeze,
27
+ engines: {}.freeze,
28
+ mime_exts: {}.freeze,
29
+ mime_types: {}.freeze,
30
+ paths: [].freeze,
31
+ pipelines: {}.freeze,
32
+ postprocessors: Hash.new { |h, k| [].freeze }.freeze,
33
+ preprocessors: Hash.new { |h, k| [].freeze }.freeze,
34
+ registered_transformers: Hash.new { |h, k| {}.freeze }.freeze,
35
+ root: File.expand_path('..', __FILE__).freeze,
36
+ transformers: Hash.new { |h, k| {}.freeze }.freeze,
37
+ version: "",
38
+ gzip_enabled: true
39
+ }.freeze
40
+ self.computed_config = {}
41
+
42
+ @context_class = Context
43
+
44
+ require 'logger'
45
+ @logger = Logger.new($stderr)
46
+ @logger.level = Logger::FATAL
47
+
48
+ # Common asset text types
49
+ register_mime_type 'application/javascript', extensions: ['.js'], charset: :unicode
50
+ register_mime_type 'application/json', extensions: ['.json'], charset: :unicode
51
+ register_mime_type 'application/xml', extensions: ['.xml']
52
+ register_mime_type 'text/css', extensions: ['.css'], charset: :css
53
+ register_mime_type 'text/html', extensions: ['.html', '.htm'], charset: :html
54
+ register_mime_type 'text/plain', extensions: ['.txt', '.text']
55
+ register_mime_type 'text/yaml', extensions: ['.yml', '.yaml'], charset: :unicode
56
+
57
+ # Common image types
58
+ register_mime_type 'image/x-icon', extensions: ['.ico']
59
+ register_mime_type 'image/bmp', extensions: ['.bmp']
60
+ register_mime_type 'image/gif', extensions: ['.gif']
61
+ register_mime_type 'image/webp', extensions: ['.webp']
62
+ register_mime_type 'image/png', extensions: ['.png']
63
+ register_mime_type 'image/jpeg', extensions: ['.jpg', '.jpeg']
64
+ register_mime_type 'image/tiff', extensions: ['.tiff', '.tif']
65
+ register_mime_type 'image/svg+xml', extensions: ['.svg']
66
+
67
+ # Common audio/video types
68
+ register_mime_type 'video/webm', extensions: ['.webm']
69
+ register_mime_type 'audio/basic', extensions: ['.snd', '.au']
70
+ register_mime_type 'audio/aiff', extensions: ['.aiff']
71
+ register_mime_type 'audio/mpeg', extensions: ['.mp3', '.mp2', '.m2a', '.m3a']
72
+ register_mime_type 'application/ogg', extensions: ['.ogx']
73
+ register_mime_type 'audio/midi', extensions: ['.midi', '.mid']
74
+ register_mime_type 'video/avi', extensions: ['.avi']
75
+ register_mime_type 'audio/wave', extensions: ['.wav', '.wave']
76
+ register_mime_type 'video/mp4', extensions: ['.mp4', '.m4v']
77
+
78
+ # Common font types
79
+ register_mime_type 'application/vnd.ms-fontobject', extensions: ['.eot']
80
+ register_mime_type 'application/x-font-opentype', extensions: ['.otf']
81
+ register_mime_type 'application/x-font-ttf', extensions: ['.ttf']
82
+ register_mime_type 'application/font-woff', extensions: ['.woff']
83
+
84
+ register_pipeline :source do |env|
85
+ []
86
+ end
87
+
88
+ register_pipeline :self do |env, type, file_type, engine_extnames|
89
+ env.self_processors_for(type, file_type, engine_extnames)
90
+ end
91
+
92
+ register_pipeline :default do |env, type, file_type, engine_extnames|
93
+ env.default_processors_for(type, file_type, engine_extnames)
94
+ end
61
95
 
62
96
  require 'sprockets/directive_processor'
63
- register_preprocessor 'text/css', DirectiveProcessor
64
- register_preprocessor 'application/javascript', DirectiveProcessor
97
+ register_preprocessor 'text/css', DirectiveProcessor.new(
98
+ comments: ["//", ["/*", "*/"]]
99
+ )
100
+ register_preprocessor 'application/javascript', DirectiveProcessor.new(
101
+ comments: ["//", ["/*", "*/"]] + ["#", ["###", "###"]]
102
+ )
65
103
 
66
- require 'sprockets/safety_colons'
67
- register_postprocessor 'application/javascript', SafetyColons
104
+ require 'sprockets/bundle'
105
+ register_bundle_processor 'application/javascript', Bundle
106
+ register_bundle_processor 'text/css', Bundle
68
107
 
69
- require 'sprockets/charset_normalizer'
70
- register_bundle_processor 'text/css', CharsetNormalizer
108
+ register_bundle_metadata_reducer '*/*', :data, proc { "" }, :concat
109
+ register_bundle_metadata_reducer 'application/javascript', :data, proc { "" }, Utils.method(:concat_javascript_sources)
110
+ register_bundle_metadata_reducer '*/*', :links, :+
71
111
 
112
+ require 'sprockets/closure_compressor'
72
113
  require 'sprockets/sass_compressor'
114
+ require 'sprockets/uglifier_compressor'
115
+ require 'sprockets/yui_compressor'
73
116
  register_compressor 'text/css', :sass, SassCompressor
74
117
  register_compressor 'text/css', :scss, SassCompressor
75
-
76
- require 'sprockets/yui_compressor'
77
118
  register_compressor 'text/css', :yui, YUICompressor
78
-
79
- require 'sprockets/closure_compressor'
80
119
  register_compressor 'application/javascript', :closure, ClosureCompressor
81
-
82
- require 'sprockets/uglifier_compressor'
83
120
  register_compressor 'application/javascript', :uglifier, UglifierCompressor
84
121
  register_compressor 'application/javascript', :uglify, UglifierCompressor
85
-
86
- require 'sprockets/yui_compressor'
87
122
  register_compressor 'application/javascript', :yui, YUICompressor
88
123
 
89
- # Cherry pick the default Tilt engines that make sense for
90
- # Sprockets. We don't need ones that only generate html like HAML.
91
-
92
124
  # Mmm, CoffeeScript
93
- register_engine '.coffee', Tilt::CoffeeScriptTemplate
125
+ require 'sprockets/coffee_script_processor'
126
+ Deprecation.silence do
127
+ register_engine '.coffee', CoffeeScriptProcessor, mime_type: 'application/javascript', silence_deprecation: true
128
+ end
94
129
 
95
130
  # JST engines
96
- register_engine '.jst', JstProcessor
97
- register_engine '.eco', EcoTemplate
98
- register_engine '.ejs', EjsTemplate
131
+ require 'sprockets/eco_processor'
132
+ require 'sprockets/ejs_processor'
133
+ require 'sprockets/jst_processor'
134
+ Deprecation.silence do
135
+ register_engine '.jst', JstProcessor, mime_type: 'application/javascript', silence_deprecation: true
136
+ register_engine '.eco', EcoProcessor, mime_type: 'application/javascript', silence_deprecation: true
137
+ register_engine '.ejs', EjsProcessor, mime_type: 'application/javascript', silence_deprecation: true
138
+ end
99
139
 
100
140
  # CSS engines
101
- register_engine '.less', Tilt::LessTemplate
102
- register_engine '.sass', SassTemplate
103
- register_engine '.scss', ScssTemplate
141
+ require 'sprockets/sass_processor'
142
+ Deprecation.silence do
143
+ register_engine '.sass', SassProcessor, mime_type: 'text/css', silence_deprecation: true
144
+ register_engine '.scss', ScssProcessor, mime_type: 'text/css', silence_deprecation: true
145
+ end
146
+ register_bundle_metadata_reducer 'text/css', :sass_dependencies, Set.new, :+
104
147
 
105
148
  # Other
106
- register_engine '.erb', Tilt::ERBTemplate
107
- register_engine '.str', Tilt::StringTemplate
149
+ require 'sprockets/erb_processor'
150
+ register_engine '.erb', ERBProcessor, mime_type: 'text/plain', silence_deprecation: true
151
+
152
+ register_dependency_resolver 'environment-version' do |env|
153
+ env.version
154
+ end
155
+ register_dependency_resolver 'environment-paths' do |env|
156
+ env.paths.map {|path| env.compress_from_root(path) }
157
+ end
158
+ register_dependency_resolver 'file-digest' do |env, str|
159
+ env.file_digest(env.parse_file_digest_uri(str))
160
+ end
161
+ register_dependency_resolver 'processors' do |env, str|
162
+ env.resolve_processors_cache_key_uri(str)
163
+ end
164
+
165
+ depend_on 'environment-version'
166
+ depend_on 'environment-paths'
108
167
  end
168
+
169
+ require 'sprockets/legacy'