Setup Gulp’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/jpachecox/setup-gulp/llms.txt
Use this file to discover all available pages before exploring further.
gulpfile.js is organised around a set of focused, composable Gulp 4 tasks. Each task handles one concern — compiling SCSS, transpiling TypeScript, optimising images, and so on — and the top-level build, watch, and serve tasks wire them together. All tasks are defined with gulp.task() and can be run individually with the gulp <taskName> command, or via the yarn script aliases defined in package.json.
All Tasks at a Glance
| Task | Run with | Purpose |
|---|---|---|
serve | yarn serve | Starts a BrowserSync dev server rooted at ./ |
watch | yarn start | Watches all src/ files and recompiles on change |
build | yarn build | Full parallel production build |
cleanAssets | yarn clean | Deletes assets/ and src/css/ contents |
sass | gulp sass | Compiles root SCSS + merges normalize.css |
sassComponents | gulp sassComponents | Compiles component SCSS with component- prefix |
sassSections | gulp sassSections | Compiles section SCSS with section- prefix |
minifyCss | gulp minifyCss | Minifies compiled CSS and outputs to assets/ |
lintScss | gulp lintScss | Lints SCSS files with gulp-sass-lint |
js | gulp js | Transpiles and minifies root TypeScript files |
jsComponents | gulp jsComponents | Transpiles component TypeScript with component- prefix |
jsSections | gulp jsSections | Transpiles section TypeScript with section- prefix |
lintJs | gulp lintJs | Lints TypeScript files with gulp-eslint |
fonts | gulp fonts | Copies fonts from src/fonts/ to assets/ |
images | gulp images | Optimises images and outputs to assets/ |
The watch Task
The watch task sets up persistent file watchers across every source directory. When a file changes, only the relevant task is triggered — keeping rebuilds fast and incremental.
| Glob | Task triggered |
|---|---|
./src/fonts/**/* | fonts |
./src/img/**/*.+(png|jpg|jpeg|gif|svg) | images |
./src/js/components/*.ts | jsComponents |
./src/js/sections/*.ts | jsSections |
./src/js/*.ts | js |
./src/scss/components/*.scss | sassComponents |
./src/scss/sections/*.scss | sassSections |
./src/scss/*.scss | sass |
./src/css/*.css | minifyCss |
The build Task
The build task runs all compilation, optimisation, and copy tasks in parallel using gulp.parallel(). It is the standard entry point for producing a fully compiled set of output files in assets/.
default task is an alias that runs build in series:
Every task pipes its source through
gulp-plumber, which catches stream errors and passes them to the handleErrors function. When a task fails, gulp-notify displays a desktop notification with the error message and gulp-util emits an audible beep. The process then exits with a non-zero code so CI pipelines register the failure correctly.