fingerprint-brunch
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "fingerprint-brunch", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A Brunch plugin for cache busting assets", | ||
@@ -5,0 +5,0 @@ "author": "David Lepaux <d.lepaux@gmail.com>", |
146
README.md
@@ -6,5 +6,6 @@ # fingerprint-brunch [![Build Status][travis-badge]][travis] | ||
- [Installation](#installation) | ||
- [Configuration](#configuration) | ||
- [Usage](#usage) | ||
- [Testing](#testing) | ||
- [Options](#options) | ||
- [Testing / Issues](#testing) | ||
- [Contributing](#contributing) | ||
- [License](#license) | ||
@@ -20,8 +21,8 @@ | ||
## <a name="configuration"></a> Configuration | ||
## <a name="usage"></a> Usage | ||
### Configuration | ||
_Optional_ You can override fingerprint-brunch's default options by updating your `brunch-config.coffee` with overrides. | ||
Default settings: | ||
```coffeescript | ||
@@ -33,58 +34,127 @@ exports.config = | ||
# Mapping file so your server can serve the right files | ||
manifest: './assets.json' | ||
# The base Path you want to remove from the `key` string in the mapping file | ||
srcBasePath: 'exemple/' | ||
# The base Path you want to remove from the `value` string in the mapping file | ||
destBasePath: 'out/' | ||
# How many digits of the SHA1. | ||
hashLength: 8 | ||
# Remove old fingerprinted files | ||
autoClearOldFiles: false | ||
# Files you want to hash, default is all else put an array of files like ['app.js', 'vendor.js', ...] | ||
targets: '*' | ||
# Environment to make hash on files | ||
environments: ['production'] | ||
# Force fingerprint-brunch to run in all environments when true. | ||
alwaysRun: false | ||
# autoReplaceAndHash assets in css/js, like a font linked in an url() in your css | ||
autoReplaceAndHash: false | ||
manifest: './path/to/assets.json' | ||
# Assets pattern | ||
assetsPatterns: new RegExp(/url\([\'\"]?[a-zA-Z0-9\-\/_.:]+\.(woff|woff2|eot|ttf|otf|jpg|jpeg|png|bmp|gif|svg)\??\#?[a-zA-Z0-9\-\/_]*[\'\"]?\)/g) | ||
# URL parameters pattern | ||
paramettersPattern: new RegExp(/(\?|\&)([^=\n]+)\=([^&\n]+)/gm) | ||
``` | ||
## <a name="usage"></a> Usage | ||
The manifest generated seem to this. | ||
### The Manifest | ||
```json | ||
{ | ||
"css/master.css": "css/master-364b42a1.css", | ||
"js/master.js": "js/master-cb60c02b.js" | ||
"js/master.js": "js/master-cb60c02b.js", | ||
"img/troll.png": "img/troll-5f2d5cbe.png", | ||
"fonts/font.eot": "fonts/font-45d860a3.eot", | ||
"fonts/font.woff": "fonts/font-6ced13b9.woff", | ||
"fonts/font.ttf": "fonts/font-82c653e7.ttf", | ||
"fonts/font.svg": "fonts/font-52343d4f.svg" | ||
} | ||
``` | ||
With the option `autoReplaceAndHash` to `true` you will have all fingerprint | ||
With `srcBasePath` and `destBasePath` you can remove some part of your path files. | ||
Like if `srcBasePath` equal to '../../public/theme/', `../../public/theme/css/master.css` begin `css/master.css`. | ||
In your code your can make a little script to read this `assets.json` and next get the real path with the key `js/master.js`. | ||
## <a name="options"></a> Options | ||
If your have any questions or suggestions, ask me ! | ||
### manifest | ||
Type: `String` | ||
Default: `./assets.json` | ||
## <a name="testing"></a> Testing | ||
Mapping fingerprinted files | ||
Just run `npm i && npm test` | ||
### srcBasePath | ||
Type: `String` | ||
Default: `exemple/` | ||
The base Path you want to remove from the `key` string in the mapping file | ||
### destBasePath | ||
Type: `String` | ||
Default: `out/` | ||
The base Path you want to remove from the `value` string in the mapping file | ||
### hashLength | ||
Type: `Integer` | ||
Default: `8` | ||
How many digits of the SHA1 | ||
### autoClearOldFiles | ||
Type: `Boolean` | ||
Default: `false` | ||
Remove old fingerprinted files (usefull in development env) | ||
### targets | ||
Type: `String|Array` | ||
Default: `*` | ||
Files you want to hash, default is all if not you can put an array of files in your `joinTo` like ['app.js', 'vendor.js', ...] | ||
### environments | ||
Type: `Array` | ||
Default: `['production']` | ||
Environment to fingerprint files | ||
### alwaysRun | ||
Type: `Boolean` | ||
Default: `false` | ||
Force fingerprint-brunch to run in all environments when true. | ||
### autoReplaceAndHash | ||
Type: `Boolean` | ||
Default: `false` | ||
Find assets in your `jointTo` files. It will be finded with `url('path/to/assets.jpg')` in your css (for now) | ||
### assetsPatterns | ||
Type: `RegExp Object` | ||
Default: `new RegExp(/url\([\'\"]?[a-zA-Z0-9\-\/_.:]+\.(woff|woff2|eot|ttf|otf|jpg|jpeg|png|bmp|gif|svg)\??\#?[a-zA-Z0-9\-\/_]*[\'\"]?\)/g)` | ||
Regex to match assets in css with `url()` attribute | ||
### paramettersPattern | ||
Type: `Regex` | ||
Default: `/(\?|\&|\#)([^=]?)([^&]*)/gm` | ||
Match hash and parameters in an URL | ||
## <a name="testing"></a> Testing / Issues | ||
Run `npm i && npm test` | ||
Know Issue on Windows : the fingerprint (hash) of `sample.css`is differents cause the sha1 lib isn't same. | ||
## <a name="contributing"></a> Contributing | ||
Pull requests are welcome. If you add functionality, then please add unit tests to cover it. | ||
## <a name="license"></a> License | ||
MIT | ||
« Copyright © | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
The Software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software. » | ||
[Brunch]: http://brunch.io | ||
[travis]: https://travis-ci.org/dlepaux/fingerprint-brunch | ||
[travis-badge]: https://img.shields.io/travis/dlepaux/fingerprint-brunch.svg?style=flat |
84694
158