sprockets 3.7.3 → 4.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +2 -299
- data/README.md +21 -35
- data/bin/sprockets +11 -8
- data/lib/rake/sprocketstask.rb +2 -2
- data/lib/sprockets/asset.rb +8 -21
- data/lib/sprockets/autoload/babel.rb +7 -0
- data/lib/sprockets/autoload/jsminc.rb +7 -0
- data/lib/sprockets/autoload/sassc.rb +7 -0
- data/lib/sprockets/autoload.rb +3 -0
- data/lib/sprockets/babel_processor.rb +58 -0
- data/lib/sprockets/base.rb +8 -8
- data/lib/sprockets/bower.rb +4 -2
- data/lib/sprockets/bundle.rb +1 -1
- data/lib/sprockets/cache.rb +2 -4
- data/lib/sprockets/closure_compressor.rb +1 -2
- data/lib/sprockets/coffee_script_processor.rb +9 -3
- data/lib/sprockets/compressing.rb +2 -2
- data/lib/sprockets/configuration.rb +1 -7
- data/lib/sprockets/context.rb +10 -18
- data/lib/sprockets/digest_utils.rb +40 -52
- data/lib/sprockets/directive_processor.rb +10 -15
- data/lib/sprockets/erb_processor.rb +1 -13
- data/lib/sprockets/http_utils.rb +19 -4
- data/lib/sprockets/jsminc_compressor.rb +31 -0
- data/lib/sprockets/jst_processor.rb +10 -10
- data/lib/sprockets/loader.rb +34 -28
- data/lib/sprockets/manifest.rb +3 -35
- data/lib/sprockets/manifest_utils.rb +0 -2
- data/lib/sprockets/mime.rb +7 -62
- data/lib/sprockets/path_dependency_utils.rb +2 -11
- data/lib/sprockets/path_digest_utils.rb +1 -1
- data/lib/sprockets/path_utils.rb +43 -18
- data/lib/sprockets/preprocessors/default_source_map.rb +24 -0
- data/lib/sprockets/processing.rb +30 -61
- data/lib/sprockets/processor_utils.rb +27 -28
- data/lib/sprockets/resolve.rb +172 -92
- data/lib/sprockets/sass_cache_store.rb +1 -6
- data/lib/sprockets/sass_compressor.rb +14 -1
- data/lib/sprockets/sass_processor.rb +18 -8
- data/lib/sprockets/sassc_compressor.rb +30 -0
- data/lib/sprockets/sassc_processor.rb +68 -0
- data/lib/sprockets/server.rb +11 -22
- data/lib/sprockets/source_map_comment_processor.rb +29 -0
- data/lib/sprockets/source_map_processor.rb +40 -0
- data/lib/sprockets/source_map_utils.rb +345 -0
- data/lib/sprockets/transformers.rb +62 -35
- data/lib/sprockets/uglifier_compressor.rb +12 -5
- data/lib/sprockets/unloaded_asset.rb +12 -11
- data/lib/sprockets/uri_tar.rb +4 -2
- data/lib/sprockets/uri_utils.rb +5 -8
- data/lib/sprockets/utils.rb +30 -79
- data/lib/sprockets/version.rb +1 -1
- data/lib/sprockets.rb +80 -35
- metadata +70 -41
- data/LICENSE +0 -21
- data/lib/sprockets/coffee_script_template.rb +0 -17
- data/lib/sprockets/deprecation.rb +0 -90
- data/lib/sprockets/eco_template.rb +0 -17
- data/lib/sprockets/ejs_template.rb +0 -17
- data/lib/sprockets/engines.rb +0 -92
- data/lib/sprockets/erb_template.rb +0 -11
- data/lib/sprockets/legacy.rb +0 -330
- data/lib/sprockets/legacy_proc_processor.rb +0 -35
- data/lib/sprockets/legacy_tilt_processor.rb +0 -29
- data/lib/sprockets/sass_template.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 60c7b56c815bf217d4f5dfaeba611132c1b69964
|
4
|
+
data.tar.gz: 0ed9b0faa7b1606dc0cba718b3ec39afeb62255e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f297befe6ef41895b1b239741c9f705c52436f902963443c6bde3b68c67e89d3dfcfec3e132ce9aa21276ae6ac7e7759d7651d3d8f00e7d0f7d68445570202a
|
7
|
+
data.tar.gz: cf82702092f023a61057f9557cae0e9f2cdcacf0a0d9cd5619bdad116a984681bd5a1a9319aaaf2ca40109be6b31107ae49ec5bea7ab5a6822514f94304ca0fb
|
data/CHANGELOG.md
CHANGED
@@ -1,300 +1,3 @@
|
|
1
|
-
**
|
1
|
+
**Master**
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
**3.7.2** (June 19, 2018)
|
6
|
-
|
7
|
-
* Security release for [CVE-2018-3760](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-3760).
|
8
|
-
|
9
|
-
**3.7.1** (December 19, 2016)
|
10
|
-
|
11
|
-
* Ruby 2.4 support for Sprockets 3.
|
12
|
-
|
13
|
-
**3.7.0** (July 21, 2016)
|
14
|
-
|
15
|
-
* Deprecated interfaces now emit deprecation warnings #345
|
16
|
-
|
17
|
-
**3.6.3** (July 1, 2016)
|
18
|
-
|
19
|
-
* Faster asset lookup in large directories #336
|
20
|
-
* Faster PathUtils.match_path_extname https://github.com/rails/sprockets/commit/697269cf81e5261fdd7072e32bd489403027fd7e
|
21
|
-
* Fixed uglifier comment stripping #326
|
22
|
-
* Error messages now show load path info #313
|
23
|
-
|
24
|
-
**3.6.2** (June 21, 2016)
|
25
|
-
|
26
|
-
* More performance improvements.
|
27
|
-
|
28
|
-
**3.6.1** (June 17, 2016)
|
29
|
-
|
30
|
-
* Some performance improvements.
|
31
|
-
|
32
|
-
**3.6.0** (April 6, 2016)
|
33
|
-
|
34
|
-
* Add `Manifest#find_sources` to return the source of the compiled assets.
|
35
|
-
* Fix the list of compressable mime types.
|
36
|
-
* Improve performance of the `FileStore` cache.
|
37
|
-
|
38
|
-
**3.5.2** (December 8, 2015)
|
39
|
-
|
40
|
-
* Fix JRuby bug with concurrent-ruby.
|
41
|
-
* Fix disabling gzip generation in cached environments.
|
42
|
-
|
43
|
-
**3.5.1** (December 5, 2015)
|
44
|
-
|
45
|
-
* Fix gzip asset generation for assets already on disk.
|
46
|
-
|
47
|
-
**3.5.0** (December 3, 2015)
|
48
|
-
|
49
|
-
* Reintroduce Gzip file generation for non-binary assets.
|
50
|
-
|
51
|
-
**3.4.1** (November 25, 2015)
|
52
|
-
|
53
|
-
* PathUtils::Entries will no longer error on an empty directory.
|
54
|
-
|
55
|
-
**3.4.0** (October 5, 2015)
|
56
|
-
|
57
|
-
* Expose method to override the sass cache in the SassProcessor.
|
58
|
-
|
59
|
-
**3.3.5** (September 25, 2015)
|
60
|
-
|
61
|
-
* Fix bug related to absolute path being reintroduced into history cache #141.
|
62
|
-
|
63
|
-
**3.3.4** (September 1, 2015)
|
64
|
-
|
65
|
-
* Relative cache contents now work with windows.
|
66
|
-
|
67
|
-
**3.3.3** (August 21, 2015)
|
68
|
-
|
69
|
-
* Remove more absolute paths from cache contents.
|
70
|
-
|
71
|
-
**3.3.2** (August 19, 2015)
|
72
|
-
|
73
|
-
* Fix cache contents to use relative paths instead of absolute paths.
|
74
|
-
|
75
|
-
**3.3.1** (August 15, 2015)
|
76
|
-
|
77
|
-
* Fix legacy Tilt integration when locals is required argument.
|
78
|
-
|
79
|
-
**3.3.0** (August 12, 2015)
|
80
|
-
|
81
|
-
* Change internal cache key to use relative asset paths instead of absolute paths.
|
82
|
-
|
83
|
-
**3.2.0** (June 2, 2015)
|
84
|
-
|
85
|
-
* Updated SRI integrity to align with spec changes
|
86
|
-
* Deprecated Manifest integrity attribute
|
87
|
-
* Cleanup concatenating JS sources with newlines
|
88
|
-
|
89
|
-
**3.1.0** (May 10, 2015)
|
90
|
-
|
91
|
-
* Removed "index" logical path normalization. Asset#logical_path is always the
|
92
|
-
full logical path to the index file.
|
93
|
-
* Fixed static asset mtimes
|
94
|
-
* Fix manifest cleanup by age
|
95
|
-
* Removed redundant minifier level cache
|
96
|
-
* Updated SRI format according to spec changes
|
97
|
-
|
98
|
-
**3.0.3** (April 27, 2015)
|
99
|
-
|
100
|
-
* Fix static asset mtime fallback
|
101
|
-
* Only warn when specified asset version can not be loaded.
|
102
|
-
|
103
|
-
**3.0.2** (April 22, 2015)
|
104
|
-
|
105
|
-
* Ensure legacy Tilt handlers return String class data. Fixes issues with Haml
|
106
|
-
Tilt handler.
|
107
|
-
* Type check and improve error messages raised on bad processor returned results.
|
108
|
-
* Improve error message for relative paths not under load path.
|
109
|
-
* Changed HTML encoding fallback from ISO-8859-1 to default external.
|
110
|
-
* Avoid falling back to 0 mtimes which may cause warnings with tar
|
111
|
-
|
112
|
-
**3.0.1** (April 14, 2015)
|
113
|
-
|
114
|
-
* Fixed `Context#depend_on` with paths outside the load path
|
115
|
-
|
116
|
-
**3.0.0** (April 12, 2015)
|
117
|
-
|
118
|
-
[Guide to upgrading from Sprockets 2.x to 3.x](https://github.com/rails/sprockets/blob/3.x/UPGRADING.md)
|
119
|
-
|
120
|
-
* New processor API. Tilt interface is deprecated.
|
121
|
-
* Improved file store caching backend.
|
122
|
-
* MIME Types now accept charset custom charset detecters. Improves support for UTF-16/32 files.
|
123
|
-
* Environment#version no longer affects asset digests. Only used for busting the asset cache.
|
124
|
-
* Removed builtin support for LESS.
|
125
|
-
* Removed `//= include` directive support.
|
126
|
-
* Deprecated `BundledAsset#to_a`. Use `BundledAsset#included` to access debugging subcomponents.
|
127
|
-
* Support circular dependencies. For parity with ES6 modules.
|
128
|
-
* Manifest compilation will no longer generate .gz files by default. [Mixing
|
129
|
-
Content-Encoding and ETags is just a bad
|
130
|
-
idea](https://issues.apache.org/bugzilla/show_bug.cgi?id=39727)
|
131
|
-
* Added linked or referenced assets. When an asset is compiled, any of its links will be compiled as well.
|
132
|
-
* Introduce some limitations around enumerating all logical paths. 4.x will deprecate it and favor linked manifests for compliation.
|
133
|
-
* Add Asset integrity attribute for Subresource Integrity
|
134
|
-
* Default digest changed to SHA256. Configuring `digest_class` is deprecated.
|
135
|
-
* Rename `Asset#digest` to `Asset#hexdigest`. `Asset#digest` is deprecated and will
|
136
|
-
return a raw byte String in 4.x.
|
137
|
-
* Added transitional compatibility flag to `Environment#resolve(path, compat: true)`. 2.x mode operates with `compat: true` and 4.x with `compat: false`
|
138
|
-
* `manifest-abc123.json` renamed to `.sprockets-abc123.json`
|
139
|
-
|
140
|
-
**2.12.3** (October 28, 2014)
|
141
|
-
|
142
|
-
* Security: Fix directory traversal bug in development mode server.
|
143
|
-
|
144
|
-
**2.12.2** (September 5, 2014)
|
145
|
-
|
146
|
-
* Ensure internal asset lookups calls are still restricted to load paths within
|
147
|
-
asset compiles. Though, you should not depend on internal asset resolves to be
|
148
|
-
completely restricted for security reasons. Assets themselves should be
|
149
|
-
considered full scripting environments with filesystem access.
|
150
|
-
|
151
|
-
**2.12.1** (April 17, 2014)
|
152
|
-
|
153
|
-
* Fix making manifest target directory when its different than the output directory.
|
154
|
-
|
155
|
-
**2.12.0** (March 13, 2014)
|
156
|
-
|
157
|
-
* Avoid context reference in SassImporter hack so its Marshallable. Fixes
|
158
|
-
issues with Sass 3.3.x.
|
159
|
-
|
160
|
-
**2.11.0** (February 19, 2014)
|
161
|
-
|
162
|
-
* Cache store must now be an LRU implementation.
|
163
|
-
* Default digest changed to SHA1. To continue using MD5.
|
164
|
-
`env.digest_class = Digest::MD5`.
|
165
|
-
|
166
|
-
**2.10.0** (May 24, 2013)
|
167
|
-
|
168
|
-
* Support for `bower.json`
|
169
|
-
|
170
|
-
**2.9.3** (April 20, 2013)
|
171
|
-
|
172
|
-
* Fixed sass caching bug
|
173
|
-
|
174
|
-
**2.9.2** (April 8, 2013)
|
175
|
-
|
176
|
-
* Improve file freshness check performance
|
177
|
-
* Directive processor encoding fixes
|
178
|
-
|
179
|
-
**2.9.1** (April 6, 2013)
|
180
|
-
|
181
|
-
* Support for Uglifier 2.x
|
182
|
-
|
183
|
-
**2.9.0** (February 25, 2013)
|
184
|
-
|
185
|
-
* Write out gzipped variants of bundled assets.
|
186
|
-
|
187
|
-
**2.8.2** (December 10, 2012)
|
188
|
-
|
189
|
-
* Fixed top level Sass constant references
|
190
|
-
* Fixed manifest logger when environment is disabled
|
191
|
-
|
192
|
-
**2.8.1** (October 31, 2012)
|
193
|
-
|
194
|
-
* Fixed Sass importer bug
|
195
|
-
|
196
|
-
**2.8.0** (October 16, 2012)
|
197
|
-
|
198
|
-
* Allow manifest location to be separated from output directory
|
199
|
-
* Pass logical path and absolute path to each_logical_path iterator
|
200
|
-
|
201
|
-
**2.7.0** (October 10, 2012)
|
202
|
-
|
203
|
-
* Added --css-compressor and --js-compressor command line flags
|
204
|
-
* Added css/js compressor shorthand
|
205
|
-
* Change default manifest.json filename to be a randomized manifest-16HEXBYTES.json
|
206
|
-
* Allow nil environment to be passed to manifest
|
207
|
-
* Allow manifest instance to be set on rake task
|
208
|
-
|
209
|
-
**2.6.0** (September 19, 2012)
|
210
|
-
|
211
|
-
* Added bower component.json require support
|
212
|
-
|
213
|
-
**2.5.0** (September 4, 2012)
|
214
|
-
|
215
|
-
* Fixed Ruby 2.0 RegExp warning
|
216
|
-
* Provide stubbed implementation of context *_path helpers
|
217
|
-
* Add SassCompressor
|
218
|
-
|
219
|
-
**2.4.5** (July 10, 2012)
|
220
|
-
|
221
|
-
* Tweaked some logger levels
|
222
|
-
|
223
|
-
**2.4.4** (July 2, 2012)
|
224
|
-
|
225
|
-
* Canonicalize logical path extensions
|
226
|
-
* Check absolute paths passed to depend_on
|
227
|
-
|
228
|
-
**2.4.3** (May 16, 2012)
|
229
|
-
|
230
|
-
* Exposed :sprockets in sass options
|
231
|
-
* Include dependency paths in asset mtime
|
232
|
-
|
233
|
-
**2.4.2** (May 7, 2012)
|
234
|
-
|
235
|
-
* Fixed MultiJson feature detect
|
236
|
-
|
237
|
-
**2.4.1** (April 26, 2012)
|
238
|
-
|
239
|
-
* Fixed MultiJson API change
|
240
|
-
* Fixed gzip mtime
|
241
|
-
|
242
|
-
**2.4.0** (March 27, 2012)
|
243
|
-
|
244
|
-
* Added global path registry
|
245
|
-
* Added global processor registry
|
246
|
-
|
247
|
-
**2.3.2** (March 26, 2012)
|
248
|
-
|
249
|
-
* Fix Context#logical_path with dots
|
250
|
-
|
251
|
-
**2.3.1** (February 11, 2012)
|
252
|
-
|
253
|
-
* Added bytesize to manifest
|
254
|
-
* Added Asset#bytesize alias
|
255
|
-
* Security: Check path for forbidden access after unescaping
|
256
|
-
|
257
|
-
**2.3.0** (January 16, 2012)
|
258
|
-
|
259
|
-
* Added special Sass importer that automatically tracks any `@import`ed files.
|
260
|
-
|
261
|
-
**2.2.0** (January 10, 2012)
|
262
|
-
|
263
|
-
* Added `sprockets` command line utility.
|
264
|
-
* Added rake/sprocketstask.
|
265
|
-
* Added json manifest log of compiled assets.
|
266
|
-
* Added `stub` directive that allows you to exclude files from the bundle.
|
267
|
-
* Added per environment external encoding (Environment#default_external_encoding). Defaults to UTF-8. Fixes issues where LANG is not set correctly and Rubys default external is set to ASCII.
|
268
|
-
|
269
|
-
**2.1.2** (November 20, 2011)
|
270
|
-
|
271
|
-
* Disabled If-Modified-Since server checks. Fixes some browser caching issues when serving the asset body only. If-None-Match caching is sufficient.
|
272
|
-
|
273
|
-
**2.1.1** (November 18, 2011)
|
274
|
-
|
275
|
-
* Fix windows absolute path check bug.
|
276
|
-
|
277
|
-
**2.1.0** (November 11, 2011)
|
278
|
-
|
279
|
-
* Directive comment lines are now turned into empty lines instead of removed. This way line numbers in
|
280
|
-
CoffeeScript syntax errors are correct.
|
281
|
-
* Performance and caching bug fixes.
|
282
|
-
|
283
|
-
**2.0.3** (October 17, 2011)
|
284
|
-
|
285
|
-
* Detect format extensions from right to left.
|
286
|
-
* Make JST namespace configurable.
|
287
|
-
|
288
|
-
**2.0.2** (October 4, 2011)
|
289
|
-
|
290
|
-
* Fixed loading stale cache from bundler gems.
|
291
|
-
|
292
|
-
**2.0.1** (September 30, 2011)
|
293
|
-
|
294
|
-
* Fixed bug with fingerprinting file names with multiple dots.
|
295
|
-
* Decode URIs as default internal.
|
296
|
-
* Fix symlinked asset directories.
|
297
|
-
|
298
|
-
**2.0.0** (August 29, 2011)
|
299
|
-
|
300
|
-
* Initial public release.
|
3
|
+
Please check the 3.x branch for previous changes https://github.com/rails/sprockets/blob/3.x/CHANGELOG.md.
|
data/README.md
CHANGED
@@ -20,21 +20,21 @@ Or include it in your project's `Gemfile` with Bundler:
|
|
20
20
|
gem 'sprockets', '~> 3.0'
|
21
21
|
```
|
22
22
|
|
23
|
-
## Using
|
23
|
+
## Using Sprockets
|
24
24
|
|
25
|
-
For most people interested in using
|
25
|
+
For most people interested in using Sprockets you will want to see [End User Asset Generation](guides/end_user_asset_generation.md) guide. This contains information about sprocket's directive syntax, and default processing behavior.
|
26
26
|
|
27
|
-
If you are a framework developer that is using
|
27
|
+
If you are a framework developer that is using Sprockets, see [Building an Asset Processing Framework](guides/building_an_asset_processing_framework.md).
|
28
28
|
|
29
|
-
If you are a library developer who is extending the functionality of
|
29
|
+
If you are a library developer who is extending the functionality of Sprockets, see [Extending Sprockets](guides/extending_sprockets.md).
|
30
30
|
|
31
|
-
Below is a disjointed mix of documentation for all three of these roles. Eventually they will be moved to an appropriate guide, for now the recommended way to consume documentation is to view the appropriate guide first and then supplement with docs from the README.
|
31
|
+
Below is a disjointed mix of documentation for all three of these roles. Eventually they will be moved to an appropriate guide, for now the recommended way to consume this documentation is to view the appropriate guide first and then supplement with docs from the README.
|
32
32
|
|
33
33
|
## Behavior
|
34
34
|
|
35
35
|
### Index files are proxies for folders
|
36
36
|
|
37
|
-
In
|
37
|
+
In Sprockets index files such as `index.js` or `index.css` files inside of a folder will generate a file with the folder's name. So if you have a `foo/index.js` file it will compile down to `foo.js`. This is similar to Node.js's behavior of using [folders as modules](https://nodejs.org/api/modules.html#modules_folders_as_modules). It is also somewhat similar to the way that a file in `public/my_folder/index.html` can be reached by a request to `/my_folder`. This means that you cannot directly use an index file. For example this would not work:
|
38
38
|
|
39
39
|
```
|
40
40
|
<%= asset_path("foo/index.js") %>
|
@@ -46,13 +46,13 @@ Instead you would need to use:
|
|
46
46
|
<%= asset_path("foo.js") %>
|
47
47
|
```
|
48
48
|
|
49
|
-
Why would you want to use this behavior? It is common behavior where you might want to include an entire directory of files in a top level javascript. You can do this in
|
49
|
+
Why would you want to use this behavior? It is common behavior where you might want to include an entire directory of files in a top level javascript. You can do this in Sprockets using `require_tree .`
|
50
50
|
|
51
51
|
```
|
52
52
|
//= require_tree .
|
53
53
|
```
|
54
54
|
|
55
|
-
This has the problem that files are required alphabetically. If your directory has `jquery-ui.js` and `jquery.min.js` then
|
55
|
+
This has the problem that files are required alphabetically. If your directory has `jquery-ui.js` and `jquery.min.js` then Sprockets will require `jquery-ui.js` before `jquery` is required which won't work (because jquery-ui depends on jquery). Previously the only way to get the correct ordering would be to rename your files, something like `0-jquery-ui.js`. Instead of doing that you can use an index file.
|
56
56
|
|
57
57
|
For example, if you have an `application.js` and want all the files in the `foo/` folder you could do this:
|
58
58
|
|
@@ -191,9 +191,9 @@ get its length in bytes, `mtime` to query its last-modified time, and
|
|
191
191
|
|
192
192
|
## Using Processors
|
193
193
|
|
194
|
-
Asset source files can be written in another format, like SCSS or
|
195
|
-
|
196
|
-
|
194
|
+
Asset source files can be written in another format, like SCSS or CoffeeScript,
|
195
|
+
and automatically compiled to CSS or JavaScript by Sprockets. Processors that
|
196
|
+
convert a file from one format to another are called *transformers*.
|
197
197
|
|
198
198
|
### Minifying Assets
|
199
199
|
|
@@ -204,6 +204,9 @@ environment.js_compressor = :uglify
|
|
204
204
|
environment.css_compressor = :scss
|
205
205
|
```
|
206
206
|
|
207
|
+
If you are using Sprockets directly with Rack app, don't forget to add
|
208
|
+
`uglifier` and `sass` gems to your Gemfile when using above options.
|
209
|
+
|
207
210
|
### Styling with Sass and SCSS
|
208
211
|
|
209
212
|
[Sass](http://sass-lang.com/) is a language that compiles to CSS and
|
@@ -219,7 +222,7 @@ new SCSS syntax, use the extension `.scss`.
|
|
219
222
|
|
220
223
|
### Scripting with CoffeeScript
|
221
224
|
|
222
|
-
[CoffeeScript](http://jashkenas.github.
|
225
|
+
[CoffeeScript](http://jashkenas.github.io/coffeescript/) is a
|
223
226
|
language that compiles to the "good parts" of JavaScript, featuring a
|
224
227
|
cleaner syntax with array comprehensions, classes, and function
|
225
228
|
binding.
|
@@ -414,12 +417,11 @@ recursively reading the file and following the directives found. This is automat
|
|
414
417
|
|
415
418
|
#### The `stub` Directive
|
416
419
|
|
417
|
-
`stub` *path*
|
420
|
+
`stub` *path* excludes that asset and its dependencies from the asset bundle.
|
418
421
|
The *path* must be a valid asset and may or may not already be part
|
419
422
|
of the bundle. `stub` should only be used at the top level bundle, not
|
420
423
|
within any subdependencies.
|
421
424
|
|
422
|
-
|
423
425
|
## Processor Interface
|
424
426
|
|
425
427
|
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.
|
@@ -478,32 +480,16 @@ def self.call(input)
|
|
478
480
|
end
|
479
481
|
```
|
480
482
|
|
483
|
+
## Contributing to Sprockets
|
481
484
|
|
482
|
-
|
483
|
-
|
484
|
-
### Contributing
|
485
|
-
|
486
|
-
The Sprockets source code is [hosted on
|
487
|
-
GitHub](https://github.com/rails/sprockets). You can check out a
|
488
|
-
copy of the latest code using Git:
|
485
|
+
Sprockets is the work of hundreds of contributors. You're encouraged to submit pull requests, propose
|
486
|
+
features and discuss issues.
|
489
487
|
|
490
|
-
|
491
|
-
|
492
|
-
If you've found a bug or have a question, please open an issue on the
|
493
|
-
[Sprockets issue
|
494
|
-
tracker](https://github.com/rails/sprockets/issues). Or, clone
|
495
|
-
the Sprockets repository, write a failing test case, fix the bug and
|
496
|
-
submit a pull request.
|
488
|
+
See [CONTRIBUTING](CONTRIBUTING.md).
|
497
489
|
|
498
490
|
### Version History
|
499
491
|
|
500
492
|
Please see the [CHANGELOG](https://github.com/rails/sprockets/tree/master/CHANGELOG.md)
|
501
493
|
|
502
494
|
## License
|
503
|
-
|
504
|
-
Copyright © 2014 Sam Stephenson <<sstephenson@gmail.com>>
|
505
|
-
|
506
|
-
Copyright © 2014 Joshua Peek <<josh@joshpeek.com>>
|
507
|
-
|
508
|
-
Sprockets is distributed under an MIT-style license. See LICENSE for
|
509
|
-
details.
|
495
|
+
Sprockets is released under the [MIT License](MIT-LICENSE).
|
data/bin/sprockets
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
$VERBOSE = nil
|
3
2
|
|
4
3
|
require 'sprockets'
|
5
4
|
require 'optparse'
|
@@ -12,7 +11,7 @@ unless ARGV.delete("--noenv")
|
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
|
14
|
+
paths = []
|
16
15
|
environment = Sprockets::Environment.new(Dir.pwd)
|
17
16
|
manifest = nil
|
18
17
|
|
@@ -52,6 +51,10 @@ OptionParser.new do |opts|
|
|
52
51
|
opts.on("--noenv", "Disables .sprocketsrc file") do
|
53
52
|
end
|
54
53
|
|
54
|
+
opts.on("--cache=DIRECTORY", "Enables the FileStore cache using the specified directory") do |directory|
|
55
|
+
environment.cache = Sprockets::Cache::FileStore.new(directory)
|
56
|
+
end
|
57
|
+
|
55
58
|
opts.on_tail("-h", "--help", "Shows this help message") do
|
56
59
|
opts.show_usage
|
57
60
|
end
|
@@ -64,8 +67,8 @@ OptionParser.new do |opts|
|
|
64
67
|
opts.show_usage if ARGV.empty?
|
65
68
|
|
66
69
|
begin
|
67
|
-
opts.order(ARGV) do |
|
68
|
-
|
70
|
+
opts.order(ARGV) do |path|
|
71
|
+
paths << path
|
69
72
|
end
|
70
73
|
rescue OptionParser::ParseError => e
|
71
74
|
opts.warn e.message
|
@@ -75,14 +78,14 @@ end
|
|
75
78
|
|
76
79
|
if environment.paths.empty?
|
77
80
|
warn "No load paths given"
|
78
|
-
warn "Usage: sprockets -Ijavascripts/
|
81
|
+
warn "Usage: sprockets -Ijavascripts/ path"
|
79
82
|
exit 1
|
80
83
|
end
|
81
84
|
|
82
85
|
if manifest
|
83
|
-
manifest.compile(
|
84
|
-
elsif
|
85
|
-
puts environment.find_asset(
|
86
|
+
manifest.compile(paths)
|
87
|
+
elsif paths.length == 1
|
88
|
+
puts environment.find_asset(paths.first).to_s
|
86
89
|
else
|
87
90
|
warn "Only one file can be compiled to stdout at a time"
|
88
91
|
exit 1
|
data/lib/rake/sprocketstask.rb
CHANGED
@@ -124,7 +124,7 @@ module Rake
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
-
task :
|
127
|
+
task clobber: ["clobber_#{name}"]
|
128
128
|
|
129
129
|
desc name == :assets ? "Clean old assets" : "Clean old #{name} assets"
|
130
130
|
task "clean_#{name}" do
|
@@ -133,7 +133,7 @@ module Rake
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
task :
|
136
|
+
task clean: ["clean_#{name}"]
|
137
137
|
end
|
138
138
|
|
139
139
|
private
|
data/lib/sprockets/asset.rb
CHANGED
@@ -13,8 +13,7 @@ module Sprockets
|
|
13
13
|
# attributes - Hash of ivars
|
14
14
|
#
|
15
15
|
# Returns Asset.
|
16
|
-
def initialize(
|
17
|
-
@environment = environment
|
16
|
+
def initialize(attributes = {})
|
18
17
|
@attributes = attributes
|
19
18
|
@content_type = attributes[:content_type]
|
20
19
|
@filename = attributes[:filename]
|
@@ -22,7 +21,6 @@ module Sprockets
|
|
22
21
|
@load_path = attributes[:load_path]
|
23
22
|
@logical_path = attributes[:logical_path]
|
24
23
|
@metadata = attributes[:metadata]
|
25
|
-
@mtime = attributes[:mtime]
|
26
24
|
@name = attributes[:name]
|
27
25
|
@source = attributes[:source]
|
28
26
|
@uri = attributes[:uri]
|
@@ -80,14 +78,6 @@ module Sprockets
|
|
80
78
|
metadata[:links] || Set.new
|
81
79
|
end
|
82
80
|
|
83
|
-
# Public: Get all internally required assets that were concated into this
|
84
|
-
# asset.
|
85
|
-
#
|
86
|
-
# Returns Array of String asset URIs.
|
87
|
-
def included
|
88
|
-
metadata[:included]
|
89
|
-
end
|
90
|
-
|
91
81
|
# Public: Return `String` of concatenated source.
|
92
82
|
#
|
93
83
|
# Returns String.
|
@@ -120,22 +110,22 @@ module Sprockets
|
|
120
110
|
end
|
121
111
|
alias_method :bytesize, :length
|
122
112
|
|
113
|
+
# Public: Returns String byte digest of source.
|
114
|
+
def digest
|
115
|
+
metadata[:digest]
|
116
|
+
end
|
117
|
+
|
123
118
|
# Public: Returns String hexdigest of source.
|
124
119
|
def hexdigest
|
125
|
-
DigestUtils.pack_hexdigest(
|
120
|
+
DigestUtils.pack_hexdigest(digest)
|
126
121
|
end
|
127
122
|
|
128
|
-
# Deprecated: Returns String hexdigest of source.
|
129
|
-
#
|
130
|
-
# In 4.x this will be changed to return a raw Digest byte String.
|
131
|
-
alias_method :digest, :hexdigest
|
132
|
-
|
133
123
|
# Pubic: ETag String of Asset.
|
134
124
|
alias_method :etag, :hexdigest
|
135
125
|
|
136
126
|
# Public: Returns String base64 digest of source.
|
137
127
|
def base64digest
|
138
|
-
DigestUtils.pack_base64digest(
|
128
|
+
DigestUtils.pack_base64digest(digest)
|
139
129
|
end
|
140
130
|
|
141
131
|
# Public: A "named information" URL for subresource integrity.
|
@@ -166,9 +156,6 @@ module Sprockets
|
|
166
156
|
f.write source
|
167
157
|
end
|
168
158
|
|
169
|
-
# Set mtime correctly
|
170
|
-
File.utime(mtime, mtime, filename)
|
171
|
-
|
172
159
|
nil
|
173
160
|
end
|
174
161
|
|
data/lib/sprockets/autoload.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
module Sprockets
|
2
2
|
module Autoload
|
3
|
+
autoload :Babel, 'sprockets/autoload/babel'
|
3
4
|
autoload :Closure, 'sprockets/autoload/closure'
|
4
5
|
autoload :CoffeeScript, 'sprockets/autoload/coffee_script'
|
5
6
|
autoload :Eco, 'sprockets/autoload/eco'
|
6
7
|
autoload :EJS, 'sprockets/autoload/ejs'
|
8
|
+
autoload :JSMinC, 'sprockets/autoload/jsminc'
|
7
9
|
autoload :Sass, 'sprockets/autoload/sass'
|
10
|
+
autoload :SassC, 'sprockets/autoload/sassc'
|
8
11
|
autoload :Uglifier, 'sprockets/autoload/uglifier'
|
9
12
|
autoload :YUI, 'sprockets/autoload/yui'
|
10
13
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'sprockets/autoload'
|
2
|
+
require 'sprockets/path_utils'
|
3
|
+
require 'sprockets/source_map_utils'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module Sprockets
|
7
|
+
class BabelProcessor
|
8
|
+
VERSION = '1'
|
9
|
+
|
10
|
+
def self.instance
|
11
|
+
@instance ||= new
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.call(input)
|
15
|
+
instance.call(input)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(options = {})
|
19
|
+
@options = options.merge({
|
20
|
+
'blacklist' => (options['blacklist'] || []) + ['useStrict'],
|
21
|
+
'sourceMap' => true
|
22
|
+
}).freeze
|
23
|
+
|
24
|
+
@cache_key = [
|
25
|
+
self.class.name,
|
26
|
+
Autoload::Babel::Transpiler::VERSION,
|
27
|
+
Autoload::Babel::Source::VERSION,
|
28
|
+
VERSION,
|
29
|
+
@options
|
30
|
+
].freeze
|
31
|
+
end
|
32
|
+
|
33
|
+
def call(input)
|
34
|
+
data = input[:data]
|
35
|
+
|
36
|
+
result = input[:cache].fetch(@cache_key + [input[:filename]] + [data]) do
|
37
|
+
opts = {
|
38
|
+
'sourceRoot' => input[:load_path],
|
39
|
+
'moduleRoot' => nil,
|
40
|
+
'filename' => input[:filename],
|
41
|
+
'filenameRelative' => PathUtils.split_subpath(input[:load_path], input[:filename])
|
42
|
+
}.merge(@options)
|
43
|
+
|
44
|
+
if opts['moduleIds'] && opts['moduleRoot']
|
45
|
+
opts['moduleId'] ||= File.join(opts['moduleRoot'], input[:name])
|
46
|
+
elsif opts['moduleIds']
|
47
|
+
opts['moduleId'] ||= input[:name]
|
48
|
+
end
|
49
|
+
Autoload::Babel::Transpiler.transform(data, opts)
|
50
|
+
end
|
51
|
+
|
52
|
+
map = SourceMapUtils.decode_json_source_map(JSON.generate(result['map']))
|
53
|
+
map = SourceMapUtils.combine_source_maps(input[:metadata][:map], map["mappings"])
|
54
|
+
|
55
|
+
{ data: result['code'], map: map }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|