gulp-rev-sri
v0.0.4
Published
A gulp-rev subresource integrity plugin
Downloads
247
Readme
gulp-rev-sri
A gulp-rev subresource integrity plugin
Table of Contents
Install
npm:
npm install gulp-rev-sri
yarn:
yarn add gulp-rev-sri
Usage
const gulp = require('gulp');
const rev = require('gulp-rev');
const revSri = require('gulp-rev-sri');
gulp.src('./myassets/**/*')
.pipe(rev())
.pipe(gulp.dest('./somedestination/'))
.pipe(rev.manifest())
.pipe(revSri({ base: 'some/build/path', manifestName: 'sri-manifest.json' }))
.pipe(gulp.dest('./somedestination/'))
.on('end', () => { ... });
// sri-manifest.json
// { <original_file>: { path: <file_with_rev_hash>, integrity: 'sha256-<hash_of_file>' } }
Options
base
- base file path for build filesmanifestName
(default:sri-manifest.json
) - name of the manifest file being created (Warning do not userev-manifest.json
)
Warning: The original rev-manifest.json
is in the format:
{
"<file_path>": "<rev_file_path>",
"<file_path>": "<rev_file_path>"
...
}
while the new sri format couples a file path with it's integrity hash in the new format of:
{
"<file_path>": {
"path": "<rev_file_path>",
"integrity": "sha256-<hash_of_file_as_base64_encoded>"
},
"<file_path>": {
"path": "<rev_file_path>",
"integrity": "sha256-<hash_of_file_as_base64_encoded>"
},
...
}
It's recommended that you choose a different file name from rev-manifest.json
due to potential complications in merging existing files.
Contributors
| Name | Website | | --------- | ------------------------- | | Shaun | https://shaunwarman.com |