1.0.8 • Published 4 years ago
@vivi-project/gulp-task v1.0.8
VIVI PROJECT:// GULP-TASK
A tool for quick and easy task creation that will avoid code repetition.
Install
$ npm i @vivi-project/gulp-taskUsage
This will be similar to how you normally create a task for Gulp. First you need to initialize the class and assign it to a variable:
import { dest } from 'gulp';
import scss from 'gulp-scss';
import autoprefixer from 'gulp-autoprefixer';
import CreateTask from '@vivi-project/gulp-task';
const task = new CreateTask('./index.scss', {allowEmpty: true});Use a setter common to determine the shared flow for modes developing and production. Setters developing and production extend stream transmitted to the common setter. The result method returns the task depending on the passed value:
import { dest } from 'gulp';
import scss from 'gulp-scss';
import autoprefixer from 'gulp-autoprefixer';
import CreateTask from '@vivi-project/gulp-task';
const task = new CreateTask('./src/index.scss', {allowEmpty: true});
task.common = src => src
.pipe(scss());
task.developing = src => src
.pipe(desc('./dest'));
task.production = src => src
.pipe(autoprefixer())
.pipe(desc('./dest'));
const devTask = task.result('dev');
const prodTask = task.result('prod');
export { devTask, prodTask }Methods
| № | Method | Description | Arguments | Returns |
|---|---|---|---|---|
| 1 | common | Define common stream | callback: () => NodeJS.ReadWriteStream | void |
| 2 | developing | Extending the general flow for developing mode | callback: (src: NodeJS.ReadWriteStream) => NodeJS.ReadWriteStream | void |
| 3 | production | Extending the general flow for production mode | callback: (src: NodeJS.ReadWriteStream) => NodeJS.ReadWriteStream | void |
| 4 | result | Getting a complete task | mode: 'dev' or 'prod' | NodeJS.ReadWriteStream |