├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── IMPLEMENTATION-EXAMPLE.md ├── IMPLEMENTATIONS.md ├── LICENSE ├── README.md ├── index.js ├── package.json └── test └── main.js /.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | node_modules/ 3 | npm-debug.log 4 | *.sublime-* 5 | .idea/ 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "4.1" 4 | - "0.12" 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## 1.0.0 The Promised Hashing 4 | 5 | ### Breaking changes 6 | 7 | - The `config` method has been removed, you can now pass a configuration options object in the `bust()` call. See the [docs](https://github.com/UltCombo/gulp-buster/#syntax) for details. 8 | - Removed the undocumented experimental `mode` option, use the new `transform` option instead. 9 | - Removed the undocumented `hashes` method. 10 | 11 | ### New features 12 | 13 | - Configuration options: added new `formatter` and `transform` options, added support for `algo` as a function and negative `length`. See the [docs](https://github.com/UltCombo/gulp-buster/#parameters) for details. 14 | - All of the configuration options which accept a function can be run asynchronously by returning a promise. 15 | - Added type validation for configuration options. 16 | 17 | ## 0.2.0 Multidimensional Configurable Hashing Abyss 18 | 19 | - `fileName` parameter is now optional and defaults to `busters.json`. 20 | - Allow multiple different output files in the same script (hashes are grouped by output filename). 21 | - Added `.config()` method to allow customizing the hashing algorithm, hash length and default output filename. 22 | 23 | ### Patch releases 24 | 25 | - **0.2.1**: Readme: Fixed miscellaneous typos, including config sample. 26 | - **0.2.2**: Fixed crash when piping an empty buffer stream into gulp-buster. Many documentation improvements: added cache busting explanation, improved syntax and architecture documentation, added 3rd-party implementations listing and contributing guide. 27 | 28 | ## 0.1.0 Bustering Gulpness 29 | 30 | - Initial release. 31 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | See [Ult Foundation Contributor's Guide](https://github.com/UltFoundation/Ultiomatic.js/blob/master/CONTRIBUTING.md). 2 | -------------------------------------------------------------------------------- /IMPLEMENTATION-EXAMPLE.md: -------------------------------------------------------------------------------- 1 | # Implementation examples 2 | 3 | **This document taken from [gulp-buster](https://github.com/UltCombo/gulp-buster) the same ideas apply here ** 4 | 5 | These examples explain the basic logic necessary to implement gulp-buster into your application. 6 | 7 | ## Node.js + Jade 8 | 9 | **asset-loader.js** 10 | ```js 11 | var busters = require('path/to/busters.json'); 12 | module.exports = function(path) { 13 | return path + (busters[path] ? '?' + busters[path] : ''); 14 | }; 15 | ``` 16 | 17 | Then when outputting cache-busted file paths, simply call the asset loader passing the (relative to project root) file path. Example with Express and Jade: 18 | 19 | ```jade 20 | script(src=fooSrc) 21 | ``` 22 | 23 | ```js 24 | var asset = require('./asset-loader.js'); 25 | res.render('view', { fooSrc: '/' + asset('js/min/foo.min.js') }, function(err, html) { 26 | // ... 27 | }); 28 | ``` 29 | 30 | As you can see, the gulp-buster `busters.json`'s paths are relative to project root without the leading slash, so we manually prepend a `/` to the cache-busted URL. This works nicely if your project root corresponds to the web server root. Otherwise, you will have to prepend the correct base URL. The optimal way would be to dynamically retrieve your app's base URL, specially as the project path relative to the web server root may differ between production and local development environments (e.g. it is a common scenario to have the project run at `/` in the production server and at `/myProject/` in local development). 31 | 32 | ## Client-side 33 | 34 | There are many ways to implement this in the front-end as well. If your project uses an AMD loader such as Require.js, you can map the modules to their cache-busted URLs in the config. Even without any loader, it is possible to `document.write` the scripts as follows: 35 | 36 | ```js 37 | ['app', 'services', 'controllers', 'filters', 'directives'].forEach(function(s) { 38 | document.write('