Web - Gulp Builder


Gulp is a task orchestrator that can:

  • serve as bundler
  • or just wrap them in a task.

Code snippet

Copy File

import gulpfile from 'gulp'
function serverCopy() {
    return gulpfile.src([
        dist + '/client/index.html',
        dist + '/client/.vite/ssr-manifest.json',
        dist + '/server/entry-server.js'

Delete File/Directory

import {deleteAsync} from 'del'
export function clean() {
    return deleteAsync([
        hostingDestination + '/*',
        serverDestination + '/*'

Execute Command (Yarn build)

import {spawn} from 'child_process';
function build(cb) {

    // We use spawn (and not exec) to get live feedback on the std streams (
    // https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
    // without the shell option, we get ENOENT (yarn is not found)
    const cmd = spawn('yarn', ['build'], {shell: true});
    cmd.stdout.on('data', (data) => {
        // process.stdout and not console.log to not add a new line
    cmd.stderr.on('data', (data) => {
        // process.stderr and not console.err to not add a new line
    cmd.on('close', function (code) {
        if (code !== 0) {
            process.stderr.write(`Error on yarn build. The process exited with the code ${code}`);
        } else {
            process.stdout.write('Yarn build was successful');


Documentation / Reference

Discover More
Gulp - Watch and Reload a Node Server

This page shows showcase how to reload a node http server with the watch possibility of gulp Below is an example of gulp.esm.js file that show case how to do it. You can adapt it to your situation....
Javascript - Transpiler (Transpiling)

A transpiler permits to take an language source and to transform it in a language target. The language source and target may be the same but with two differents version. compiling A transpiler permits...
Web - Build Operations / Build Pipeline

This page is the build operation for the web. A build pipeline will: transform (compile) bundle and optimize web code html, css (less, ...) Javascript (Javascript Module, React Jsx,...
Web Node Build - Task runner orchestrator

A Task runner (orchestrator) is a build tool that permits to run all kind of task (generally build operations) in serie or parallel. A task runner works on a stream of file selected from the file system...

Share this page:
Follow us:
Task Runner