sprockets 3.0.0.beta.6 → 3.0.0.beta.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +171 -100
- data/lib/rake/sprocketstask.rb +2 -2
- data/lib/sprockets.rb +69 -63
- data/lib/sprockets/asset.rb +2 -61
- data/lib/sprockets/autoload_processor.rb +48 -0
- data/lib/sprockets/base.rb +4 -6
- data/lib/sprockets/bower.rb +8 -5
- data/lib/sprockets/bundle.rb +9 -13
- data/lib/sprockets/cache.rb +19 -14
- data/lib/sprockets/cache/file_store.rb +2 -1
- data/lib/sprockets/cached_environment.rb +15 -68
- data/lib/sprockets/closure_compressor.rb +17 -4
- data/lib/sprockets/coffee_script_processor.rb +26 -0
- data/lib/sprockets/coffee_script_template.rb +3 -20
- data/lib/sprockets/compressing.rb +10 -4
- data/lib/sprockets/configuration.rb +21 -37
- data/lib/sprockets/context.rb +37 -67
- data/lib/sprockets/dependencies.rb +73 -0
- data/lib/sprockets/digest_utils.rb +8 -2
- data/lib/sprockets/directive_processor.rb +122 -165
- data/lib/sprockets/eco_processor.rb +32 -0
- data/lib/sprockets/eco_template.rb +3 -26
- data/lib/sprockets/ejs_processor.rb +31 -0
- data/lib/sprockets/ejs_template.rb +3 -25
- data/lib/sprockets/encoding_utils.rb +9 -21
- data/lib/sprockets/engines.rb +25 -27
- data/lib/sprockets/environment.rb +9 -1
- data/lib/sprockets/erb_processor.rb +30 -0
- data/lib/sprockets/erb_template.rb +3 -20
- data/lib/sprockets/file_reader.rb +15 -0
- data/lib/sprockets/http_utils.rb +2 -0
- data/lib/sprockets/jst_processor.rb +9 -2
- data/lib/sprockets/legacy.rb +212 -3
- data/lib/sprockets/legacy_tilt_processor.rb +1 -1
- data/lib/sprockets/loader.rb +95 -89
- data/lib/sprockets/manifest.rb +23 -59
- data/lib/sprockets/mime.rb +28 -41
- data/lib/sprockets/path_dependency_utils.rb +76 -0
- data/lib/sprockets/path_utils.rb +21 -1
- data/lib/sprockets/paths.rb +23 -8
- data/lib/sprockets/processing.rb +102 -91
- data/lib/sprockets/processor_utils.rb +97 -0
- data/lib/sprockets/resolve.rb +110 -97
- data/lib/sprockets/sass_cache_store.rb +2 -2
- data/lib/sprockets/sass_compressor.rb +17 -4
- data/lib/sprockets/sass_functions.rb +2 -2
- data/lib/sprockets/sass_importer.rb +2 -2
- data/lib/sprockets/sass_processor.rb +305 -0
- data/lib/sprockets/sass_template.rb +4 -286
- data/lib/sprockets/server.rb +1 -13
- data/lib/sprockets/transformers.rb +62 -25
- data/lib/sprockets/uglifier_compressor.rb +17 -4
- data/lib/sprockets/uri_utils.rb +190 -0
- data/lib/sprockets/utils.rb +87 -6
- data/lib/sprockets/version.rb +1 -1
- data/lib/sprockets/yui_compressor.rb +17 -4
- metadata +14 -5
- data/lib/sprockets/asset_uri.rb +0 -80
- data/lib/sprockets/lazy_processor.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d55da847286c101c972d4726a09af4abb94d5580
|
4
|
+
data.tar.gz: 1a5ffd86bcfafcf7524efc61224b2e95a4bd2633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74bd05cb90faa8f43acbfaa7d68678d4dec71dda98a752c60a8889e3374881690aef1b414e86a3180fe843411185943339d3393d62d1e4d93c8effbb13bce094
|
7
|
+
data.tar.gz: c60422ed4c47b110be53585ffd66b7b8dc1080b3321585471c57cb38eedbc1d5c39272247cc4662888fa985559da2e3575bdeed9ca0b3fe404a54103802ac53f
|
data/README.md
CHANGED
@@ -5,20 +5,26 @@ It features declarative dependency management for JavaScript and CSS
|
|
5
5
|
assets, as well as a powerful preprocessor pipeline that allows you to
|
6
6
|
write assets in languages like CoffeeScript, Sass and SCSS.
|
7
7
|
|
8
|
-
|
8
|
+
|
9
|
+
## Installation
|
9
10
|
|
10
11
|
Install Sprockets from RubyGems:
|
11
12
|
|
12
|
-
|
13
|
+
``` sh
|
14
|
+
$ gem install sprockets
|
15
|
+
```
|
13
16
|
|
14
17
|
Or include it in your project's `Gemfile` with Bundler:
|
15
18
|
|
16
|
-
|
19
|
+
``` ruby
|
20
|
+
gem 'sprockets', '~> 3.0'
|
21
|
+
```
|
22
|
+
|
17
23
|
|
18
|
-
|
24
|
+
## Understanding the Sprockets Environment
|
19
25
|
|
20
26
|
You'll need an instance of the `Sprockets::Environment` class to
|
21
|
-
access and serve assets from your application. Under Rails
|
27
|
+
access and serve assets from your application. Under Rails 4.0 and
|
22
28
|
later, `YourApp::Application.assets` is a preconfigured
|
23
29
|
`Sprockets::Environment` instance. For Rack-based applications, create
|
24
30
|
an instance in `config.ru`.
|
@@ -28,7 +34,7 @@ assets, manipulating the load path, and registering processors. It is
|
|
28
34
|
also a Rack application that can be mounted at a URL to serve assets
|
29
35
|
over HTTP.
|
30
36
|
|
31
|
-
|
37
|
+
### The Load Path
|
32
38
|
|
33
39
|
The *load path* is an ordered list of directories that Sprockets uses
|
34
40
|
to search for assets.
|
@@ -42,29 +48,31 @@ The power of the load path is that it lets you organize your source
|
|
42
48
|
files into multiple directories -- even directories that live outside
|
43
49
|
your application -- and combine those directories into a single
|
44
50
|
virtual filesystem. That means you can easily bundle JavaScript, CSS
|
45
|
-
and images into a Ruby library and import them into your application.
|
51
|
+
and images into a Ruby library or [Bower](http://bower.io) package and import them into your application.
|
46
52
|
|
47
|
-
|
53
|
+
#### Manipulating the Load Path
|
48
54
|
|
49
55
|
To add a directory to your environment's load path, use the
|
50
56
|
`append_path` and `prepend_path` methods. Directories at the beginning
|
51
57
|
of the load path have precedence over subsequent directories.
|
52
58
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
59
|
+
``` ruby
|
60
|
+
environment = Sprockets::Environment.new
|
61
|
+
environment.append_path 'app/assets/javascripts'
|
62
|
+
environment.append_path 'lib/assets/javascripts'
|
63
|
+
environment.append_path 'vendor/assets/bower_components'
|
64
|
+
```
|
57
65
|
|
58
66
|
In general, you should append to the path by default and reserve
|
59
67
|
prepending for cases where you need to override existing assets.
|
60
68
|
|
61
|
-
|
69
|
+
### Accessing Assets
|
62
70
|
|
63
71
|
Once you've set up your environment's load path, you can mount the
|
64
72
|
environment as a Rack server and request assets via HTTP. You can also
|
65
73
|
access assets programmatically from within your application.
|
66
74
|
|
67
|
-
|
75
|
+
#### Logical Paths
|
68
76
|
|
69
77
|
Assets in Sprockets are always referenced by their *logical path*.
|
70
78
|
|
@@ -90,7 +98,7 @@ contains the directory `app/assets/javascripts`:
|
|
90
98
|
In this way, all directories in the load path are merged to create a
|
91
99
|
virtual filesystem whose entries are logical paths.
|
92
100
|
|
93
|
-
|
101
|
+
#### Serving Assets Over HTTP
|
94
102
|
|
95
103
|
When you mount an environment, all of its assets are accessible as
|
96
104
|
logical paths underneath the *mount point*. For example, if you mount
|
@@ -98,48 +106,48 @@ your environment at `/assets` and request the URL
|
|
98
106
|
`/assets/application.js`, Sprockets will search your load path for the
|
99
107
|
file named `application.js` and serve it.
|
100
108
|
|
101
|
-
Under Rails
|
109
|
+
Under Rails 4.0 and later, your Sprockets environment is automatically
|
102
110
|
mounted at `/assets`. If you are using Sprockets with a Rack
|
103
111
|
application, you will need to mount the environment yourself. A good
|
104
112
|
way to do this is with the `map` method in `config.ru`:
|
105
113
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
114
|
+
``` ruby
|
115
|
+
require 'sprockets'
|
116
|
+
map '/assets' do
|
117
|
+
environment = Sprockets::Environment.new
|
118
|
+
environment.append_path 'app/assets/javascripts'
|
119
|
+
environment.append_path 'app/assets/stylesheets'
|
120
|
+
run environment
|
121
|
+
end
|
122
|
+
|
123
|
+
map '/' do
|
124
|
+
run YourRackApp
|
125
|
+
end
|
126
|
+
```
|
117
127
|
|
118
|
-
|
128
|
+
#### Accessing Assets Programmatically
|
119
129
|
|
120
130
|
You can use the `find_asset` method (aliased as `[]`) to retrieve an
|
121
131
|
asset from a Sprockets environment. Pass it a logical path and you'll
|
122
|
-
get a `Sprockets::
|
132
|
+
get a `Sprockets::Asset` instance back:
|
123
133
|
|
124
|
-
|
125
|
-
|
134
|
+
``` ruby
|
135
|
+
environment['application.js']
|
136
|
+
# => #<Sprockets::Asset ...>
|
137
|
+
```
|
126
138
|
|
127
139
|
Call `to_s` on the resulting asset to access its contents, `length` to
|
128
140
|
get its length in bytes, `mtime` to query its last-modified time, and
|
129
141
|
`filename` to get its full path on the filesystem.
|
130
142
|
|
131
|
-
# Using Engines #
|
132
143
|
|
133
|
-
|
134
|
-
CoffeeScript, and automatically compiled to CSS or JavaScript by
|
135
|
-
Sprockets. Compilers for these languages are called *engines*.
|
144
|
+
## Using Processors
|
136
145
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
might have the name `dialog.js.coffee`.
|
146
|
+
Asset source files can be written in another format, like SCSS or
|
147
|
+
CoffeeScript, and automatically compiled to CSS or JavaScript by
|
148
|
+
Sprockets. Processors that convert a file from one format to another are called *transformers*.
|
141
149
|
|
142
|
-
|
150
|
+
### Minifying Assets
|
143
151
|
|
144
152
|
Several JavaScript and CSS minifiers are available through shorthand.
|
145
153
|
|
@@ -148,7 +156,7 @@ environment.js_compressor = :uglify
|
|
148
156
|
environment.css_compressor = :scss
|
149
157
|
```
|
150
158
|
|
151
|
-
|
159
|
+
### Styling with Sass and SCSS
|
152
160
|
|
153
161
|
[Sass](http://sass-lang.com/) is a language that compiles to CSS and
|
154
162
|
adds features like nested rules, variables, mixins and selector
|
@@ -158,10 +166,10 @@ If the `sass` gem is available to your application, you can use Sass
|
|
158
166
|
to write CSS assets in Sprockets.
|
159
167
|
|
160
168
|
Sprockets supports both Sass syntaxes. For the original
|
161
|
-
whitespace-sensitive syntax, use the extension `.
|
162
|
-
new SCSS syntax, use the extension `.
|
169
|
+
whitespace-sensitive syntax, use the extension `.sass`. For the
|
170
|
+
new SCSS syntax, use the extension `.scss`.
|
163
171
|
|
164
|
-
|
172
|
+
### Scripting with CoffeeScript
|
165
173
|
|
166
174
|
[CoffeeScript](http://jashkenas.github.com/coffee-script/) is a
|
167
175
|
language that compiles to the "good parts" of JavaScript, featuring a
|
@@ -175,9 +183,9 @@ an [ExecJS](https://github.com/sstephenson/execjs)-supported runtime
|
|
175
183
|
on your system to invoke it.
|
176
184
|
|
177
185
|
To write JavaScript assets with CoffeeScript, use the extension
|
178
|
-
`.
|
186
|
+
`.coffee`.
|
179
187
|
|
180
|
-
|
188
|
+
### JavaScript Templating with EJS and Eco
|
181
189
|
|
182
190
|
Sprockets supports *JavaScript templates* for client-side rendering of
|
183
191
|
strings or markup. JavaScript templates have the special format
|
@@ -188,12 +196,14 @@ logical path as a property on the global `JST` object. Invoke a
|
|
188
196
|
template function to render the template as a string. The resulting
|
189
197
|
string can then be inserted into the DOM.
|
190
198
|
|
191
|
-
|
192
|
-
|
199
|
+
```
|
200
|
+
<!-- templates/hello.jst.ejs -->
|
201
|
+
<div>Hello, <span><%= name %></span>!</div>
|
193
202
|
|
194
|
-
|
195
|
-
|
196
|
-
|
203
|
+
// application.js
|
204
|
+
//= require templates/hello
|
205
|
+
$("#hello").html(JST["templates/hello"]({ name: "Sam" }));
|
206
|
+
```
|
197
207
|
|
198
208
|
Sprockets supports two JavaScript template languages:
|
199
209
|
[EJS](https://github.com/sstephenson/ruby-ejs), for embedded
|
@@ -210,17 +220,12 @@ templates have the extension `.jst.eco`. Note that the `eco` gem
|
|
210
220
|
depends on the CoffeeScript compiler, so the same caveats apply as
|
211
221
|
outlined above for the CoffeeScript engine.
|
212
222
|
|
213
|
-
|
223
|
+
### Invoking Ruby with ERB
|
214
224
|
|
215
225
|
Sprockets provides an ERB engine for preprocessing assets using
|
216
226
|
embedded Ruby code. Append `.erb` to a CSS or JavaScript asset's
|
217
227
|
filename to enable the ERB engine.
|
218
228
|
|
219
|
-
**Note**: Sprockets processes multiple engine extensions in order from
|
220
|
-
right to left, so you can use multiple engines with a single
|
221
|
-
asset. For example, to have a CoffeeScript asset that is first
|
222
|
-
preprocessed with ERB, use the extension `.js.coffee.erb`.
|
223
|
-
|
224
229
|
Ruby code embedded in an asset is evaluated in the context of a
|
225
230
|
`Sprockets::Context` instance for the given asset. Common uses for ERB
|
226
231
|
include:
|
@@ -236,13 +241,8 @@ include:
|
|
236
241
|
See the [Helper Methods](lib/sprockets/context.rb) section for more information about
|
237
242
|
interacting with `Sprockets::Context` instances via ERB.
|
238
243
|
|
239
|
-
### String Interpolation Syntax ###
|
240
|
-
|
241
|
-
If you need access to Ruby from an asset but cannot use ERB's `<% …
|
242
|
-
%>` syntax, Sprockets also supports Ruby string interpolation syntax
|
243
|
-
(`#{ … }`) with the `.str` engine extension.
|
244
244
|
|
245
|
-
|
245
|
+
## Managing and Bundling Dependencies
|
246
246
|
|
247
247
|
You can create *asset bundles* -- ordered concatenations of asset
|
248
248
|
source files -- by specifying dependencies in a special comment syntax
|
@@ -253,16 +253,18 @@ them to recursively build a dependency graph. When you request an
|
|
253
253
|
asset with dependencies, the dependencies will be included in order at
|
254
254
|
the top of the file.
|
255
255
|
|
256
|
-
|
256
|
+
### The Directive Processor
|
257
257
|
|
258
258
|
Sprockets runs the *directive processor* on each CSS and JavaScript
|
259
259
|
source file. The directive processor scans for comment lines beginning
|
260
260
|
with `=` in comment blocks at the top of the file.
|
261
261
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
262
|
+
``` js
|
263
|
+
//= require jquery
|
264
|
+
//= require jquery-ui
|
265
|
+
//= require backbone
|
266
|
+
//= require_tree .
|
267
|
+
```
|
266
268
|
|
267
269
|
The first word immediately following `=` specifies the directive
|
268
270
|
name. Any words following the directive name are treated as
|
@@ -274,21 +276,27 @@ contain spaces, similar to commands in the Unix shell.
|
|
274
276
|
processing. Sprockets will not look for directives in comment blocks
|
275
277
|
that occur after the first line of code.
|
276
278
|
|
277
|
-
|
279
|
+
#### Supported Comment Types
|
278
280
|
|
279
281
|
The directive processor understands comment blocks in three formats:
|
280
282
|
|
281
|
-
|
282
|
-
|
283
|
-
|
283
|
+
``` css
|
284
|
+
/* Multi-line comment blocks (CSS, SCSS, JavaScript)
|
285
|
+
*= require foo
|
286
|
+
*/
|
287
|
+
```
|
284
288
|
|
285
|
-
|
286
|
-
|
289
|
+
``` js
|
290
|
+
// Single-line comment blocks (SCSS, JavaScript)
|
291
|
+
//= require foo
|
292
|
+
```
|
287
293
|
|
288
|
-
|
289
|
-
|
294
|
+
``` coffee
|
295
|
+
# Single-line comment blocks (CoffeeScript)
|
296
|
+
#= require foo
|
297
|
+
```
|
290
298
|
|
291
|
-
|
299
|
+
### Sprockets Directives
|
292
300
|
|
293
301
|
You can use the following directives to declare dependencies in asset
|
294
302
|
source files.
|
@@ -297,7 +305,7 @@ For directives that take a *path* argument, you may specify either a
|
|
297
305
|
logical path or a relative path. Relative paths begin with `./` and
|
298
306
|
reference files relative to the location of the current file.
|
299
307
|
|
300
|
-
|
308
|
+
#### The `require` Directive
|
301
309
|
|
302
310
|
`require` *path* inserts the contents of the asset source file
|
303
311
|
specified by *path*. If the file is required multiple times, it will
|
@@ -309,35 +317,35 @@ appear in the bundle only once.
|
|
309
317
|
format in the directory specified by *path*. Files are required in
|
310
318
|
alphabetical order.
|
311
319
|
|
312
|
-
|
320
|
+
#### The `require_tree` Directive
|
313
321
|
|
314
322
|
`require_tree` *path* works like `require_directory`, but operates
|
315
323
|
recursively to require all files in all subdirectories of the
|
316
324
|
directory specified by *path*.
|
317
325
|
|
318
|
-
|
326
|
+
#### The `require_self` Directive
|
319
327
|
|
320
328
|
`require_self` tells Sprockets to insert the body of the current
|
321
329
|
source file before any subsequent `require` directives.
|
322
330
|
|
323
|
-
|
331
|
+
#### The `link` Directive
|
324
332
|
|
325
333
|
`link` *path* declares a dependency on the target *path* and adds it to a list
|
326
334
|
of subdependencies to automatically be compiled when the asset is written out to
|
327
335
|
disk.
|
328
336
|
|
329
337
|
For an example, in a CSS file you might reference an external image that always
|
330
|
-
|
338
|
+
needs to be compiled along with the css file.
|
331
339
|
|
332
340
|
``` css
|
333
|
-
|
341
|
+
/*= link "logo.png" */
|
334
342
|
.logo {
|
335
343
|
background-image: url(logo.png)
|
336
344
|
}
|
337
345
|
```
|
338
346
|
|
339
|
-
However, if you use a `asset-path
|
340
|
-
automatically be
|
347
|
+
However, if you use a `asset-path` or `asset-url` SCSS helper, these links will
|
348
|
+
automatically be defined for you.
|
341
349
|
|
342
350
|
``` css
|
343
351
|
.logo {
|
@@ -345,33 +353,93 @@ automatically be setup for you.
|
|
345
353
|
}
|
346
354
|
```
|
347
355
|
|
348
|
-
|
356
|
+
#### The `depend_on` Directive
|
349
357
|
|
350
358
|
`depend_on` *path* declares a dependency on the given *path* without
|
351
359
|
including it in the bundle. This is useful when you need to expire an
|
352
360
|
asset's cache in response to a change in another file.
|
353
361
|
|
354
|
-
|
362
|
+
#### The `depend_on_asset` Directive
|
355
363
|
|
356
364
|
`depend_on_asset` *path* works like `depend_on`, but operates
|
357
|
-
recursively reading the file and following the directives found.
|
365
|
+
recursively reading the file and following the directives found. This is automatically implied if you use `link`, so consider if it just makes sense using `link` instead of `depend_on_asset`.
|
358
366
|
|
359
|
-
|
367
|
+
#### The `stub` Directive
|
360
368
|
|
361
369
|
`stub` *path* allows dependency to be excluded from the asset bundle.
|
362
370
|
The *path* must be a valid asset and may or may not already be part
|
363
371
|
of the bundle. `stub` should only be used at the top level bundle, not
|
364
372
|
within any subdependencies.
|
365
373
|
|
366
|
-
# Development #
|
367
374
|
|
368
|
-
##
|
375
|
+
## Processor Interface
|
376
|
+
|
377
|
+
Sprockets 2.x was originally design around [Tilt](https://github.com/rtomayko/tilt)'s engine interface. However, starting with 3.x, a new interface has been introduced deprecating Tilt.
|
378
|
+
|
379
|
+
Similar to Rack, a processor is a any "callable" (an object that responds to `call`). This maybe a simple Proc or a full class that defines a `def self.call(input)` method. The `call` method accepts an `input` Hash and returns a Hash of metadata.
|
380
|
+
|
381
|
+
Also see [`Sprockets::ProcessorUtils`](https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/processor_utils.rb) for public helper methods.
|
382
|
+
|
383
|
+
### input Hash
|
384
|
+
|
385
|
+
The `input` Hash defines the following public fields.
|
386
|
+
|
387
|
+
* `:data` - String asset contents
|
388
|
+
* `:environment` - Current `Sprockets::Environment` instance.
|
389
|
+
* `:cache` - A `Sprockets::Cache` instance. See [`Sprockets::Cache#fetch`](https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/cache.rb).
|
390
|
+
* `:uri` - String Asset URI.
|
391
|
+
* `:filename` - String full path to original file.
|
392
|
+
* `:load_path` - String current load path for filename.
|
393
|
+
* `:name` - String logical path for filename.
|
394
|
+
* `:content_type` - String content type of the output asset.
|
395
|
+
* `:metadata` - Hash of processor metadata.
|
396
|
+
|
397
|
+
``` ruby
|
398
|
+
def self.call(input)
|
399
|
+
input[:cache].fetch("my:cache:key:v1") do
|
400
|
+
# Remove all semicolons from source
|
401
|
+
input[:data].gsub(";", "")
|
402
|
+
end
|
403
|
+
end
|
404
|
+
```
|
405
|
+
|
406
|
+
### return Hash
|
407
|
+
|
408
|
+
The processor should return metadata `Hash`. With the exception of the `:data` key, the processor can store arbitrary JSON valid values in this Hash. The data will be stored and exposed on `Asset#metadata`.
|
409
|
+
|
410
|
+
The returned `:data` replaces the assets `input[:data]` to the next processor in the chain. Returning a `String` is shorthand for returning `{ data: str }`. And returning `nil` is shorthand for a no-op where the input data is not transformed, `{ data: input[:data] }`.
|
411
|
+
|
412
|
+
### metadata
|
413
|
+
|
414
|
+
The metadata Hash provides an open format for processors to extend the pipeline processor. Internally, built-in processors use it for passing data to each other.
|
415
|
+
|
416
|
+
* `:required` - A `Set` of String Asset URIs that the Bundle processor should concatenate together.
|
417
|
+
* `:stubbed` - A `Set` of String Asset URIs that will be omitted from the `:required` set.
|
418
|
+
* `:links` - A `Set` of String Asset URIs that should be compiled along with this asset.
|
419
|
+
* `:dependencies` - A `Set` of String Cache URIs that should be monitored for caching.
|
420
|
+
|
421
|
+
``` ruby
|
422
|
+
def self.call(input)
|
423
|
+
# Any metadata may start off as nil, so initialize it the value
|
424
|
+
required = Set.new(input[:metadata][:required])
|
425
|
+
|
426
|
+
# Manually add "foo.js" asset uri to our bundle
|
427
|
+
required << input[:environment].resolve("foo.js")
|
428
|
+
|
429
|
+
{ required: required }
|
430
|
+
end
|
431
|
+
```
|
432
|
+
|
433
|
+
|
434
|
+
## Development
|
435
|
+
|
436
|
+
### Contributing
|
369
437
|
|
370
438
|
The Sprockets source code is [hosted on
|
371
439
|
GitHub](https://github.com/sstephenson/sprockets). You can check out a
|
372
440
|
copy of the latest code using Git:
|
373
441
|
|
374
|
-
$ git clone https://github.com/sstephenson/sprockets
|
442
|
+
$ git clone https://github.com/sstephenson/sprockets
|
375
443
|
|
376
444
|
If you've found a bug or have a question, please open an issue on the
|
377
445
|
[Sprockets issue
|
@@ -379,25 +447,28 @@ tracker](https://github.com/sstephenson/sprockets/issues). Or, clone
|
|
379
447
|
the Sprockets repository, write a failing test case, fix the bug and
|
380
448
|
submit a pull request.
|
381
449
|
|
382
|
-
|
450
|
+
### Version History
|
383
451
|
|
384
452
|
**3.0.0**
|
385
453
|
|
454
|
+
* New processor API. Tilt interface is deprecated.
|
455
|
+
* Improved file store caching backend.
|
386
456
|
* MIME Types now accept charset custom charset detecters. Improves support for UTF-16/32 files.
|
387
457
|
* Environment#version no longer affects asset digests. Only used for busting the asset cache.
|
388
458
|
* Removed builtin support for LESS.
|
389
|
-
* Removed include directive support.
|
390
|
-
* Deprecated BundledAsset#to_a
|
459
|
+
* Removed `//= include` directive support.
|
460
|
+
* Deprecated `BundledAsset#to_a`. Use `BundledAsset#included` to access debugging subcomponents.
|
391
461
|
* Support circular dependencies. For parity with ES6 modules.
|
392
462
|
* Manifest compilation will no longer generate .gz files by default. [Mixing
|
393
463
|
Content-Encoding and ETags is just a bad
|
394
464
|
idea](https://issues.apache.org/bugzilla/show_bug.cgi?id=39727)
|
395
|
-
* Added linked or referenced assets. When an asset is compiled, any of its links
|
396
|
-
|
465
|
+
* Added linked or referenced assets. When an asset is compiled, any of its links will be compiled as well.
|
466
|
+
* Introduce some limitations around enumerating all logical paths. 4.x will deprecate it and favor linked manifests for compliation.
|
397
467
|
* Add Asset integrity attribute for Subresource Integrity
|
398
|
-
* Default digest changed to SHA256. Configuring digest_class is deprecated.
|
399
|
-
* Rename Asset#digest to Asset#hexdigest
|
468
|
+
* Default digest changed to SHA256. Configuring `digest_class` is deprecated.
|
469
|
+
* Rename `Asset#digest` to `Asset#hexdigest`. `Asset#digest` is deprecated and will
|
400
470
|
return a raw byte String in 4.x.
|
471
|
+
* Added transitional compatibility flag to `Environment#resolve(path, compat: true)`. 2.x mode operates with `compat: true` and 4.x with `compat: false`
|
401
472
|
|
402
473
|
**2.12.3** (October 28, 2014)
|
403
474
|
|
@@ -561,7 +632,7 @@ submit a pull request.
|
|
561
632
|
|
562
633
|
* Initial public release.
|
563
634
|
|
564
|
-
|
635
|
+
## License
|
565
636
|
|
566
637
|
Copyright © 2014 Sam Stephenson <<sstephenson@gmail.com>>
|
567
638
|
|