LinuxCommandLibrary

gulp

Automate front-end development workflows

TLDR

Run the default task

$ gulp
copy

Run individual tasks
$ gulp [task] [othertask]
copy

Print the task dependency tree for the loaded gulpfile
$ gulp --tasks
copy

SYNOPSIS

gulp [taskname] [options]
gulp [command] [options]
gulp --version

PARAMETERS

--gulpfile <file>
    Specify an alternative gulpfile.js path to load.

--cwd <path>
    Specify an alternative working directory to run gulp from.

--tasks
    Print a formatted tree of all available tasks defined in the gulpfile.

--tasks-simple
    Print a plain, unformatted list of available tasks.

--tasks-json
    Print tasks in JSON format for programmatic use.

--require <module>
    Preload a Node.js module before running the gulpfile.

--version
    Print the global gulp-cli and local gulp package versions.

--verify
    Verify global and local gulp version compatibility.

--compact-tasks
    Hide tasks that are marked as hidden by description.

--continue
    Continue running subsequent tasks even if a task fails.

--silent
    Disable all logging output during task execution.

--series
    Force all tasks to run sequentially (overrides default parallel for some cases).

--parallel
    Force all tasks to run concurrently (overrides default series for some cases).

--no-color
    Disable colored output in the console.

--help
    Display help information for the gulp command and its options.

--log-level <level>
    Set the minimum log level for output (e.g., 'info', 'warn', 'error').

--log-timestamps
    Add timestamps to log messages for better tracking.

--stack-trace
    Print the full JavaScript stack trace on error for debugging.

DESCRIPTION

Please note: gulp is not a standard Linux command built into the operating system. It is a popular JavaScript task runner primarily used in web development, built on Node.js and installed via npm.

gulp automates repetitive development tasks such as code minification, compilation (e.g., Sass to CSS, TypeScript to JavaScript), concatenation, testing, and deployment. It operates on a 'code-over-configuration' paradigm, where tasks are defined using JavaScript in a file named gulpfile.js. This approach leverages Node.js streams for efficient file processing, allowing transformations to happen in memory without writing intermediate files to disk, leading to faster build times. It's highly extensible through a vast ecosystem of plugins, enabling developers to customize build workflows efficiently.

CAVEATS

gulp is not a native Linux utility; it fundamentally relies on Node.js and its package manager npm being installed on the system. It functions as a project-specific tool, meaning you typically install a global gulp-cli for command-line access and a local gulp package as a development dependency within each project. Its entire functionality is defined by the JavaScript tasks written in a project's gulpfile.js, making it highly flexible but requiring a JavaScript development environment.

INSTALLATION

To use gulp globally from your terminal, first install the gulp-cli package: npm install -g gulp-cli. For each project, you then need to install the local gulp package as a development dependency: npm install --save-dev gulp.

GULPFILE.JS

The central configuration and task definition file for gulp is named gulpfile.js, located in the root of your project. This file is written in JavaScript and uses gulp.src() to read files, .pipe() to apply transformations using plugins, gulp.dest() to write processed files, and gulp.series() or gulp.parallel() to compose tasks.

HISTORY

gulp was initially developed by Eric Schoffstall and released in 2013. It gained rapid popularity as a modern alternative to existing JavaScript task runners like Grunt. Its core philosophy emphasized 'code-over-configuration' and leveraged Node.js streams for efficient, in-memory processing of files. This design often resulted in faster build times and a more programmatic, less declarative approach to defining build workflows. Its development has continued with focus on performance, plugin ecosystem, and an intuitive API for front-end automation.

SEE ALSO

npm(1): Node.js package manager, used to install gulp and its plugins., node(1): Node.js runtime, which executes gulp tasks and the underlying JavaScript code., webpack: A popular module bundler, often used for similar front-end asset compilation and optimization tasks., grunt: Another well-known JavaScript task runner, which gulp emerged as an alternative to, focusing on streams and code-based configuration.

Copied to clipboard