1.0.3 • Published 4 years ago

@wok-cli/task-rev v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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 to false to skip execution.

Parameters

parametertypedefaultnote
patternstringstring[]Globs source files to rewrite (1)
deststringDestination folder (1)
manifeststringManifest file path (1)
hook:(*)objectHooks configuration parameters (see below)
  1. Supports environment templates.

Hooks

nametypedescription
beforelazypipeExecuted before file revving
afterlazypipeExecuted after file revving (source files have been deleted)
rewritelazypipeExecuted before revved source files are updated by gulp-rev-rewrite

Example

This example task will perform the following actions:

  1. match the files with the provided glob pattern
  2. create a new file with a unique rev hash appended to it's name
  3. 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',
});