@wok-cli/task-rev
v1.0.3
Published
A sharable Wok task implementing file revving
Downloads
6
Readme
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-devEnvironmental variables
This task adds the following environmental variables:
rev: (boolean) Set tofalseto 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',
});