sprockets 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +72 -0
  3. data/README.md +665 -0
  4. data/bin/sprockets +93 -0
  5. data/lib/rake/sprocketstask.rb +153 -0
  6. data/lib/sprockets.rb +229 -0
  7. data/lib/sprockets/add_source_map_comment_to_asset_processor.rb +60 -0
  8. data/lib/sprockets/asset.rb +202 -0
  9. data/lib/sprockets/autoload.rb +16 -0
  10. data/lib/sprockets/autoload/babel.rb +8 -0
  11. data/lib/sprockets/autoload/closure.rb +8 -0
  12. data/lib/sprockets/autoload/coffee_script.rb +8 -0
  13. data/lib/sprockets/autoload/eco.rb +8 -0
  14. data/lib/sprockets/autoload/ejs.rb +8 -0
  15. data/lib/sprockets/autoload/jsminc.rb +8 -0
  16. data/lib/sprockets/autoload/sass.rb +8 -0
  17. data/lib/sprockets/autoload/sassc.rb +8 -0
  18. data/lib/sprockets/autoload/uglifier.rb +8 -0
  19. data/lib/sprockets/autoload/yui.rb +8 -0
  20. data/lib/sprockets/autoload/zopfli.rb +7 -0
  21. data/lib/sprockets/babel_processor.rb +66 -0
  22. data/lib/sprockets/base.rb +147 -0
  23. data/lib/sprockets/bower.rb +61 -0
  24. data/lib/sprockets/bundle.rb +105 -0
  25. data/lib/sprockets/cache.rb +271 -0
  26. data/lib/sprockets/cache/file_store.rb +208 -0
  27. data/lib/sprockets/cache/memory_store.rb +75 -0
  28. data/lib/sprockets/cache/null_store.rb +54 -0
  29. data/lib/sprockets/cached_environment.rb +64 -0
  30. data/lib/sprockets/closure_compressor.rb +48 -0
  31. data/lib/sprockets/coffee_script_processor.rb +39 -0
  32. data/lib/sprockets/compressing.rb +134 -0
  33. data/lib/sprockets/configuration.rb +79 -0
  34. data/lib/sprockets/context.rb +304 -0
  35. data/lib/sprockets/dependencies.rb +74 -0
  36. data/lib/sprockets/digest_utils.rb +200 -0
  37. data/lib/sprockets/directive_processor.rb +414 -0
  38. data/lib/sprockets/eco_processor.rb +33 -0
  39. data/lib/sprockets/ejs_processor.rb +32 -0
  40. data/lib/sprockets/encoding_utils.rb +262 -0
  41. data/lib/sprockets/environment.rb +46 -0
  42. data/lib/sprockets/erb_processor.rb +37 -0
  43. data/lib/sprockets/errors.rb +12 -0
  44. data/lib/sprockets/exporters/base.rb +71 -0
  45. data/lib/sprockets/exporters/file_exporter.rb +24 -0
  46. data/lib/sprockets/exporters/zlib_exporter.rb +33 -0
  47. data/lib/sprockets/exporters/zopfli_exporter.rb +14 -0
  48. data/lib/sprockets/exporting.rb +73 -0
  49. data/lib/sprockets/file_reader.rb +16 -0
  50. data/lib/sprockets/http_utils.rb +135 -0
  51. data/lib/sprockets/jsminc_compressor.rb +32 -0
  52. data/lib/sprockets/jst_processor.rb +50 -0
  53. data/lib/sprockets/loader.rb +345 -0
  54. data/lib/sprockets/manifest.rb +338 -0
  55. data/lib/sprockets/manifest_utils.rb +48 -0
  56. data/lib/sprockets/mime.rb +96 -0
  57. data/lib/sprockets/npm.rb +52 -0
  58. data/lib/sprockets/path_dependency_utils.rb +77 -0
  59. data/lib/sprockets/path_digest_utils.rb +48 -0
  60. data/lib/sprockets/path_utils.rb +367 -0
  61. data/lib/sprockets/paths.rb +82 -0
  62. data/lib/sprockets/preprocessors/default_source_map.rb +49 -0
  63. data/lib/sprockets/processing.rb +228 -0
  64. data/lib/sprockets/processor_utils.rb +169 -0
  65. data/lib/sprockets/resolve.rb +295 -0
  66. data/lib/sprockets/sass_cache_store.rb +30 -0
  67. data/lib/sprockets/sass_compressor.rb +63 -0
  68. data/lib/sprockets/sass_functions.rb +3 -0
  69. data/lib/sprockets/sass_importer.rb +3 -0
  70. data/lib/sprockets/sass_processor.rb +313 -0
  71. data/lib/sprockets/sassc_compressor.rb +56 -0
  72. data/lib/sprockets/sassc_processor.rb +297 -0
  73. data/lib/sprockets/server.rb +295 -0
  74. data/lib/sprockets/source_map_processor.rb +66 -0
  75. data/lib/sprockets/source_map_utils.rb +483 -0
  76. data/lib/sprockets/transformers.rb +173 -0
  77. data/lib/sprockets/uglifier_compressor.rb +66 -0
  78. data/lib/sprockets/unloaded_asset.rb +139 -0
  79. data/lib/sprockets/uri_tar.rb +99 -0
  80. data/lib/sprockets/uri_utils.rb +191 -0
  81. data/lib/sprockets/utils.rb +202 -0
  82. data/lib/sprockets/utils/gzip.rb +99 -0
  83. data/lib/sprockets/version.rb +4 -0
  84. data/lib/sprockets/yui_compressor.rb +56 -0
  85. metadata +444 -0
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env ruby
2
+ $VERBOSE = nil
3
+
4
+ require 'sprockets'
5
+ require 'optparse'
6
+ require 'shellwords'
7
+
8
+ unless ARGV.delete("--noenv")
9
+ if File.exist?(path = "./.sprocketsrc")
10
+ rcflags = Shellwords.split(File.read(path))
11
+ ARGV.unshift(*rcflags)
12
+ end
13
+ end
14
+
15
+ paths = []
16
+ environment = Sprockets::Environment.new(Dir.pwd)
17
+ manifest = nil
18
+
19
+ (ENV['SPROCKETS_PATH'] || "").split(File::PATH_SEPARATOR).each do |path|
20
+ environment.append_path path
21
+ end
22
+
23
+ OptionParser.new do |opts|
24
+ opts.summary_width = 28
25
+ opts.banner = "Usage: sprockets [options] filename [filename ...]"
26
+
27
+ def opts.show_usage
28
+ puts self
29
+ exit 1
30
+ end
31
+
32
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before doing anything") do |lib|
33
+ require lib
34
+ end
35
+
36
+ opts.on("-I DIRECTORY", "--include=DIRECTORY", "Adds the directory to the Sprockets load path") do |directory|
37
+ environment.append_path directory
38
+ end
39
+
40
+ opts.on("-o DIRECTORY", "--output=DIRECTORY", "Copy provided assets into DIRECTORY") do |directory|
41
+ manifest = Sprockets::Manifest.new(environment, directory)
42
+ end
43
+
44
+ opts.on("--css-compressor=COMPRESSOR", "Use CSS compressor") do |compressor|
45
+ environment.css_compressor = compressor.to_sym
46
+ end
47
+
48
+ opts.on("--js-compressor=COMPRESSOR", "Use JavaScript compressor") do |compressor|
49
+ environment.js_compressor = compressor.to_sym
50
+ end
51
+
52
+ opts.on("--noenv", "Disables .sprocketsrc file") do
53
+ end
54
+
55
+ opts.on("--cache=DIRECTORY", "Enables the FileStore cache using the specified directory") do |directory|
56
+ environment.cache = Sprockets::Cache::FileStore.new(directory)
57
+ end
58
+
59
+ opts.on_tail("-h", "--help", "Shows this help message") do
60
+ opts.show_usage
61
+ end
62
+
63
+ opts.on_tail("-v", "--version", "Shows version") do
64
+ puts Sprockets::VERSION
65
+ exit
66
+ end
67
+
68
+ opts.show_usage if ARGV.empty?
69
+
70
+ begin
71
+ opts.order(ARGV) do |path|
72
+ paths << path
73
+ end
74
+ rescue OptionParser::ParseError => e
75
+ opts.warn e.message
76
+ opts.show_usage
77
+ end
78
+ end
79
+
80
+ if environment.paths.empty?
81
+ warn "No load paths given"
82
+ warn "Usage: sprockets -Ijavascripts/ path"
83
+ exit 1
84
+ end
85
+
86
+ if manifest
87
+ manifest.compile(paths)
88
+ elsif paths.length == 1
89
+ puts environment.find_asset(paths.first).to_s
90
+ else
91
+ warn "Only one file can be compiled to stdout at a time"
92
+ exit 1
93
+ end
@@ -0,0 +1,153 @@
1
+ # frozen_string_literal: true
2
+ require 'rake'
3
+ require 'rake/tasklib'
4
+
5
+ require 'sprockets'
6
+ require 'logger'
7
+
8
+ module Rake
9
+ # Simple Sprockets compilation Rake task macro.
10
+ #
11
+ # Rake::SprocketsTask.new do |t|
12
+ # t.environment = Sprockets::Environment.new
13
+ # t.output = "./public/assets"
14
+ # t.assets = %w( application.js application.css )
15
+ # end
16
+ #
17
+ class SprocketsTask < Rake::TaskLib
18
+ # Name of the task. Defaults to "assets".
19
+ #
20
+ # The name will also be used to suffix the clean and clobber
21
+ # tasks, "clean_assets" and "clobber_assets".
22
+ attr_accessor :name
23
+
24
+ # `Environment` instance used for finding assets.
25
+ #
26
+ # You'll most likely want to reassign `environment` to your own.
27
+ #
28
+ # Rake::SprocketsTask.new do |t|
29
+ # t.environment = Foo::Assets
30
+ # end
31
+ #
32
+ def environment
33
+ if !@environment.is_a?(Sprockets::Base) && @environment.respond_to?(:call)
34
+ @environment = @environment.call
35
+ else
36
+ @environment
37
+ end
38
+ end
39
+ attr_writer :environment
40
+
41
+ # Returns cached cached environment
42
+ def cached
43
+ @cached ||= environment.cached if environment
44
+ end
45
+ alias_method :index, :cached
46
+
47
+ # `Manifest` instance used for already compiled assets.
48
+ #
49
+ # Will be created by default if an environment and output
50
+ # directory are given
51
+ def manifest
52
+ if !@manifest.is_a?(Sprockets::Manifest) && @manifest.respond_to?(:call)
53
+ @manifest = @manifest.call
54
+ else
55
+ @manifest
56
+ end
57
+ end
58
+ attr_writer :manifest
59
+
60
+ # Directory to write compiled assets too. As well as the manifest file.
61
+ #
62
+ # t.output = "./public/assets"
63
+ #
64
+ attr_accessor :output
65
+
66
+ # Array of asset logical paths to compile.
67
+ #
68
+ # t.assets = %w( application.js jquery.js application.css )
69
+ #
70
+ attr_accessor :assets
71
+
72
+ # Number of old assets to keep.
73
+ attr_accessor :keep
74
+
75
+ # Logger to use during rake tasks. Defaults to using stderr.
76
+ #
77
+ # t.logger = Logger.new($stdout)
78
+ #
79
+ attr_accessor :logger
80
+
81
+ # Returns logger level Integer.
82
+ def log_level
83
+ @logger.level
84
+ end
85
+
86
+ # Set logger level with constant or symbol.
87
+ #
88
+ # t.log_level = Logger::INFO
89
+ # t.log_level = :debug
90
+ #
91
+ def log_level=(level)
92
+ if level.is_a?(Integer)
93
+ @logger.level = level
94
+ else
95
+ @logger.level = Logger.const_get(level.to_s.upcase)
96
+ end
97
+ end
98
+
99
+ def initialize(name = :assets)
100
+ @name = name
101
+ @environment = lambda { Sprockets::Environment.new(Dir.pwd) }
102
+ @manifest = lambda { Sprockets::Manifest.new(cached, output) }
103
+ @logger = Logger.new($stderr)
104
+ @logger.level = Logger::INFO
105
+ @keep = 2
106
+
107
+ yield self if block_given?
108
+
109
+ define
110
+ end
111
+
112
+ # Define tasks
113
+ def define
114
+ desc name == :assets ? "Compile assets" : "Compile #{name} assets"
115
+ task name do
116
+ with_logger do
117
+ manifest.compile(assets)
118
+ end
119
+ end
120
+
121
+ desc name == :assets ? "Remove all assets" : "Remove all #{name} assets"
122
+ task "clobber_#{name}" do
123
+ with_logger do
124
+ manifest.clobber
125
+ end
126
+ end
127
+
128
+ task clobber: ["clobber_#{name}"]
129
+
130
+ desc name == :assets ? "Clean old assets" : "Clean old #{name} assets"
131
+ task "clean_#{name}" do
132
+ with_logger do
133
+ manifest.clean(keep)
134
+ end
135
+ end
136
+
137
+ task clean: ["clean_#{name}"]
138
+ end
139
+
140
+ private
141
+ # Sub out environment logger with our rake task logger that
142
+ # writes to stderr.
143
+ def with_logger
144
+ if env = manifest.environment
145
+ old_logger = env.logger
146
+ env.logger = @logger
147
+ end
148
+ yield
149
+ ensure
150
+ env.logger = old_logger if env
151
+ end
152
+ end
153
+ end
@@ -0,0 +1,229 @@
1
+ # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ require 'sprockets/version'
5
+ require 'sprockets/cache'
6
+ require 'sprockets/environment'
7
+ require 'sprockets/errors'
8
+ require 'sprockets/manifest'
9
+
10
+ module Sprockets
11
+ require 'sprockets/processor_utils'
12
+ extend ProcessorUtils
13
+
14
+ # Extend Sprockets module to provide global registry
15
+ require 'sprockets/configuration'
16
+ require 'sprockets/context'
17
+ require 'digest/sha2'
18
+ extend Configuration
19
+
20
+ self.config = {
21
+ bundle_processors: Hash.new { |h, k| [].freeze }.freeze,
22
+ bundle_reducers: Hash.new { |h, k| {}.freeze }.freeze,
23
+ compressors: Hash.new { |h, k| {}.freeze }.freeze,
24
+ dependencies: Set.new.freeze,
25
+ dependency_resolvers: {}.freeze,
26
+ digest_class: Digest::SHA256,
27
+ mime_exts: {}.freeze,
28
+ mime_types: {}.freeze,
29
+ paths: [].freeze,
30
+ pipelines: {}.freeze,
31
+ pipeline_exts: {}.freeze,
32
+ postprocessors: Hash.new { |h, k| [].freeze }.freeze,
33
+ preprocessors: Hash.new { |h, k| [].freeze }.freeze,
34
+ registered_transformers: [].freeze,
35
+ root: __dir__.dup.freeze,
36
+ transformers: Hash.new { |h, k| {}.freeze }.freeze,
37
+ exporters: Hash.new { |h, k| Set.new.freeze }.freeze,
38
+ version: "",
39
+ gzip_enabled: true,
40
+ export_concurrent: true
41
+ }.freeze
42
+
43
+ @context_class = Context
44
+
45
+ require 'logger'
46
+ @logger = Logger.new($stderr)
47
+ @logger.level = Logger::FATAL
48
+
49
+ # Common asset text types
50
+ register_mime_type 'application/javascript', extensions: ['.js'], charset: :unicode
51
+ register_mime_type 'application/json', extensions: ['.json'], charset: :unicode
52
+ register_mime_type 'application/ruby', extensions: ['.rb']
53
+ register_mime_type 'application/xml', extensions: ['.xml']
54
+ register_mime_type 'text/css', extensions: ['.css'], charset: :css
55
+ register_mime_type 'text/html', extensions: ['.html', '.htm'], charset: :html
56
+ register_mime_type 'text/plain', extensions: ['.txt', '.text']
57
+ register_mime_type 'text/yaml', extensions: ['.yml', '.yaml'], charset: :unicode
58
+
59
+ # Common image types
60
+ register_mime_type 'image/x-icon', extensions: ['.ico']
61
+ register_mime_type 'image/bmp', extensions: ['.bmp']
62
+ register_mime_type 'image/gif', extensions: ['.gif']
63
+ register_mime_type 'image/webp', extensions: ['.webp']
64
+ register_mime_type 'image/png', extensions: ['.png']
65
+ register_mime_type 'image/jpeg', extensions: ['.jpg', '.jpeg']
66
+ register_mime_type 'image/tiff', extensions: ['.tiff', '.tif']
67
+ register_mime_type 'image/svg+xml', extensions: ['.svg']
68
+
69
+ # Common audio/video types
70
+ register_mime_type 'video/webm', extensions: ['.webm']
71
+ register_mime_type 'audio/basic', extensions: ['.snd', '.au']
72
+ register_mime_type 'audio/aiff', extensions: ['.aiff']
73
+ register_mime_type 'audio/mpeg', extensions: ['.mp3', '.mp2', '.m2a', '.m3a']
74
+ register_mime_type 'application/ogg', extensions: ['.ogx']
75
+ register_mime_type 'audio/ogg', extensions: ['.ogg', '.oga']
76
+ register_mime_type 'audio/midi', extensions: ['.midi', '.mid']
77
+ register_mime_type 'video/avi', extensions: ['.avi']
78
+ register_mime_type 'audio/wave', extensions: ['.wav', '.wave']
79
+ register_mime_type 'video/mp4', extensions: ['.mp4', '.m4v']
80
+ register_mime_type 'audio/aac', extensions: ['.aac']
81
+ register_mime_type 'audio/mp4', extensions: ['.m4a']
82
+ register_mime_type 'audio/flac', extensions: ['.flac']
83
+
84
+ # Common font types
85
+ register_mime_type 'application/vnd.ms-fontobject', extensions: ['.eot']
86
+ register_mime_type 'application/x-font-opentype', extensions: ['.otf']
87
+ register_mime_type 'application/x-font-ttf', extensions: ['.ttf']
88
+ register_mime_type 'application/font-woff', extensions: ['.woff']
89
+ register_mime_type 'application/font-woff2', extensions: ['.woff2']
90
+
91
+ require 'sprockets/source_map_processor'
92
+ register_mime_type 'application/js-sourcemap+json', extensions: ['.js.map']
93
+ register_mime_type 'application/css-sourcemap+json', extensions: ['.css.map']
94
+ register_transformer 'application/javascript', 'application/js-sourcemap+json', SourceMapProcessor
95
+ register_transformer 'text/css', 'application/css-sourcemap+json', SourceMapProcessor
96
+
97
+ register_pipeline :source do |env|
98
+ []
99
+ end
100
+
101
+ register_pipeline :self do |env, type, file_type|
102
+ env.self_processors_for(type, file_type)
103
+ end
104
+
105
+ register_pipeline :default do |env, type, file_type|
106
+ env.default_processors_for(type, file_type)
107
+ end
108
+
109
+ require 'sprockets/add_source_map_comment_to_asset_processor'
110
+ register_pipeline :debug do
111
+ [AddSourceMapCommentToAssetProcessor]
112
+ end
113
+
114
+ require 'sprockets/directive_processor'
115
+ register_preprocessor 'text/css', DirectiveProcessor.new(comments: ["//", ["/*", "*/"]])
116
+ register_preprocessor 'application/javascript', DirectiveProcessor.new(comments: ["//", ["/*", "*/"]])
117
+
118
+ require 'sprockets/bundle'
119
+ register_bundle_processor 'application/javascript', Bundle
120
+ register_bundle_processor 'text/css', Bundle
121
+
122
+ register_bundle_metadata_reducer '*/*', :data, proc { +"" }, :concat
123
+ register_bundle_metadata_reducer 'application/javascript', :data, proc { +"" }, Utils.method(:concat_javascript_sources)
124
+ register_bundle_metadata_reducer '*/*', :links, :+
125
+ register_bundle_metadata_reducer '*/*', :sources, proc { [] }, :+
126
+
127
+ require 'sprockets/closure_compressor'
128
+ require 'sprockets/sass_compressor'
129
+ require 'sprockets/sassc_compressor'
130
+ require 'sprockets/jsminc_compressor'
131
+ require 'sprockets/uglifier_compressor'
132
+ require 'sprockets/yui_compressor'
133
+ register_compressor 'text/css', :sass, SassCompressor
134
+ register_compressor 'text/css', :sassc, SasscCompressor
135
+ register_compressor 'text/css', :scss, SassCompressor
136
+ register_compressor 'text/css', :scssc, SasscCompressor
137
+ register_compressor 'text/css', :yui, YUICompressor
138
+ register_compressor 'application/javascript', :closure, ClosureCompressor
139
+ register_compressor 'application/javascript', :jsmin, JSMincCompressor
140
+ register_compressor 'application/javascript', :jsminc, JSMincCompressor
141
+ register_compressor 'application/javascript', :uglifier, UglifierCompressor
142
+ register_compressor 'application/javascript', :uglify, UglifierCompressor
143
+ register_compressor 'application/javascript', :yui, YUICompressor
144
+
145
+ # Babel, TheFuture™ is now
146
+ require 'sprockets/babel_processor'
147
+ register_mime_type 'application/ecmascript-6', extensions: ['.es6'], charset: :unicode
148
+ register_transformer 'application/ecmascript-6', 'application/javascript', BabelProcessor
149
+ register_preprocessor 'application/ecmascript-6', DirectiveProcessor.new(comments: ["//", ["/*", "*/"]])
150
+
151
+ # Mmm, CoffeeScript
152
+ require 'sprockets/coffee_script_processor'
153
+ register_mime_type 'text/coffeescript', extensions: ['.coffee', '.js.coffee']
154
+ register_transformer 'text/coffeescript', 'application/javascript', CoffeeScriptProcessor
155
+ register_preprocessor 'text/coffeescript', DirectiveProcessor.new(comments: ["#", ["###", "###"]])
156
+
157
+ # JST processors
158
+ require 'sprockets/eco_processor'
159
+ require 'sprockets/ejs_processor'
160
+ require 'sprockets/jst_processor'
161
+ register_mime_type 'text/eco', extensions: ['.eco', '.jst.eco']
162
+ register_mime_type 'text/ejs', extensions: ['.ejs', '.jst.ejs']
163
+ register_transformer 'text/eco', 'application/javascript+function', EcoProcessor
164
+ register_transformer 'text/ejs', 'application/javascript+function', EjsProcessor
165
+ register_transformer 'application/javascript+function', 'application/javascript', JstProcessor
166
+
167
+ # CSS processors
168
+ require 'sprockets/sassc_processor'
169
+ register_mime_type 'text/sass', extensions: ['.sass', '.css.sass']
170
+ register_mime_type 'text/scss', extensions: ['.scss', '.css.scss']
171
+ register_transformer 'text/sass', 'text/css', SasscProcessor
172
+ register_transformer 'text/scss', 'text/css', ScsscProcessor
173
+ register_preprocessor 'text/sass', DirectiveProcessor.new(comments: ["//", ["/*", "*/"]])
174
+ register_preprocessor 'text/scss', DirectiveProcessor.new(comments: ["//", ["/*", "*/"]])
175
+ register_bundle_metadata_reducer 'text/css', :sass_dependencies, Set.new, :+
176
+
177
+ # ERB
178
+ require 'sprockets/erb_processor'
179
+ register_transformer_suffix(%w(
180
+ application/ecmascript-6
181
+ application/javascript
182
+ application/json
183
+ application/xml
184
+ text/coffeescript
185
+ text/css
186
+ text/html
187
+ text/plain
188
+ text/sass
189
+ text/scss
190
+ text/yaml
191
+ text/eco
192
+ ), 'application/\2+ruby', '.erb', ERBProcessor)
193
+
194
+ register_mime_type 'application/html+ruby', extensions: ['.html.erb', '.erb', '.rhtml'], charset: :html
195
+ register_mime_type 'application/xml+ruby', extensions: ['.xml.erb', '.rxml']
196
+
197
+ require 'sprockets/exporters/file_exporter'
198
+ require 'sprockets/exporters/zlib_exporter'
199
+ require 'sprockets/exporters/zopfli_exporter'
200
+ register_exporter '*/*', Exporters::FileExporter
201
+ register_exporter '*/*', Exporters::ZlibExporter
202
+
203
+ register_dependency_resolver 'environment-version' do |env|
204
+ env.version
205
+ end
206
+ register_dependency_resolver 'environment-paths' do |env|
207
+ env.paths.map {|path| env.compress_from_root(path) }
208
+ end
209
+ register_dependency_resolver 'file-digest' do |env, str|
210
+ env.file_digest(env.parse_file_digest_uri(str))
211
+ end
212
+ register_dependency_resolver 'processors' do |env, str|
213
+ env.resolve_processors_cache_key_uri(str)
214
+ end
215
+ register_dependency_resolver 'env' do |env, str|
216
+ _, var = str.split(':', 2)
217
+ ENV[var]
218
+ end
219
+
220
+ depend_on 'environment-version'
221
+ depend_on 'environment-paths'
222
+
223
+ require 'sprockets/preprocessors/default_source_map'
224
+ register_preprocessor 'text/css', Preprocessors::DefaultSourceMap.new
225
+ register_preprocessor 'application/javascript', Preprocessors::DefaultSourceMap.new
226
+
227
+ register_bundle_metadata_reducer 'text/css', :map, proc { |input| { "version" => 3, "file" => PathUtils.split_subpath(input[:load_path], input[:filename]), "sections" => [] } }, SourceMapUtils.method(:concat_source_maps)
228
+ register_bundle_metadata_reducer 'application/javascript', :map, proc { |input| { "version" => 3, "file" => PathUtils.split_subpath(input[:load_path], input[:filename]), "sections" => [] } }, SourceMapUtils.method(:concat_source_maps)
229
+ end