API Reference

gulp

Streaming build system that automates tasks with composable pipelines using src, dest, series, and parallel helpers.

Official Documentation ↗
CompatibilityThis documentation covers version v5. Check the official docs for the latest API surface.

Installation

npmnpm install --save-dev gulp
pnpmpnpm add -D gulp

Methods

Overview

gulp is a streaming build system that automates file tasks with composable src, dest, series, and parallel pipelines. This reference lists the most frequently used APIs with accurate signatures and runnable snippets.

Core APIs

  • gulp.src — Creates a readable stream of files matched by the given glob patterns.
  • gulp.series — Composes tasks that must run in order, the default for dependent build steps.
  • gulp.watch — Watches files and reruns tasks when matching files change.

Example

const { src, dest } = require('gulp');

function copy() {
  return src('src/**/*.css').pipe(dest('dist'));
}
exports.copy = copy;

Notes

Tasks must return a stream or promise so gulp can await completion. Gulp 5 changed stream internals, so some older plugins need updates.

Verification

Run a copy task and confirm the destination contains exactly the matched source files with identical contents.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://gulpjs.com/docs/en/api/concepts · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:50:10.457Z.

FAQ

Why is my task not waiting for completion?
Return the stream or a promise from the task function; otherwise gulp cannot know when the async work finished.
What is the difference between series and parallel?
series runs tasks sequentially respecting order, while parallel starts tasks concurrently for independent work.
How do I migrate plugins that broke in gulp 5?
Gulp 5 switches to a new stream style; check for a maintained release of each plugin, otherwise replace it with a native stream transform.