@wok-cli/task-scripts
v1.0.2
Published
A general sharable wok task to manage scripts
Downloads
4
Readme
Scripts Task
Sharable tasks for scripts.
By default the task just copies scripts from source to destination. Use one of the hooks to transform the source code.
Installation
This task requires @wok-cli/core
as peer dependency.
npm i @wok-cli/core @wok-cli/task-scripts --save-dev
Parameters
| parameter | type | default | note |
| ------------ | ------------------ | ------- | --------------------------------------------------------- |
| src
| stringstring[] | | Globs source files (1) |
| dest
| string | | Destination folder (1) |
| sourcemaps
| stringboolean | | Write sourcemaps. See here for details(2) |
| hook:(*)
| object | | Hooks configuration parameters (see below) |
- Supports environment templates.
- Defaults to the value of
$.env.sourcemaps
.
Hooks
| name | type | description |
| ----------- | ------------- | ----------------------------------------------------------------------------------- |
| pre
| lazypipe | Executed before transform
hook |
| transform
| lazypipe | Use this hook to transform source code with tools like Babel |
| post
| lazypipe | Executed just before writing the file to disk |
Example
const $ = require('@wok-cli/core');
const scripts = require('@wok-cli/task-scripts');
exports.scripts = $.task(scripts, {
src: ['src/assets/js/**/*.js'],
dest: 'public/assets/js',
});
Usage with gulp-babel
const $ = require('@wok-cli/core');
const scripts = require('@wok-cli/task-scripts');
const babel = require('gulp-babel');
const scriptsTask = $.task(scripts, {
src: ['src/assets/js/**/*.js'],
dest: 'public/assets/js',
});
scriptsTask.tap('transform', 'babel', (lazypipe) => {
return lazypipe.pipe(
babel,
{
// babel configuration here...
},
);
});
exports.scripts = scriptsTask;