1.0.3 • Published 4 years ago
@wok-cli/task-rev v1.0.3
Rev Task
Sharable tasks to apply a unique hash to file names. Implements the following gulp plugins:
Note This task will be applied just on production.
Installation
This task requires @wok-cli/core
as peer dependency.
npm i @wok-cli/core @wok-cli/task-rev --save-dev
Environmental variables
This task adds the following environmental variables:
rev
: (boolean) Set tofalse
to skip execution.
Parameters
parameter | type | default | note |
---|---|---|---|
pattern | stringstring[] | Globs source files to rewrite (1) | |
dest | string | Destination folder (1) | |
manifest | string | Manifest file path (1) | |
hook:(*) | object | Hooks configuration parameters (see below) |
- Supports environment templates.
Hooks
name | type | description |
---|---|---|
before | lazypipe | Executed before file revving |
after | lazypipe | Executed after file revving (source files have been deleted) |
rewrite | lazypipe | Executed before revved source files are updated by gulp-rev-rewrite |
Example
This example task will perform the following actions:
- match the files with the provided glob pattern
- create a new file with a unique rev hash appended to it's name
- remove the original files
const $ = require('@wok-cli/core');
const rev = require('@wok-cli/task-rev');
exports.rev = $.task(rev, {
pattern: ['public/**/*.{js,css}'],
dest: 'public',
manifest: 'public/manifest.json',
});