gulp-tron
v0.9.5
Published
Easy to use gulp build manager
Readme
gulp-tron
Easy-to-use, configuration-driven build manager for Gulp projects.
- Simple task creation through configuration
- Fluent API for manipulating build streams
- Dependency management for task execution
- Automatic generation of
@cleanand@watchtasks - BrowserSync integration for watch workflows
- Plugin support for extending and reusing build processes
Installation
You can use any package manager of your choice. Here are some examples:
bun add -d gulp gulp-tron
# or
npm i --save-dev gulp gulp-tron
# or
pnpm add -D gulp gulp-tron
# or
yarn add -D gulp gulp-trongulp is a peer dependency and should be installed alongside gulp-tron.
Quick example
import tron from "gulp-tron";
const scripts = {
name: "scripts",
src: "src/**/*.js",
dest: "dist/js",
build: (bs) => bs.src().pipe(/* plugin */).dest(),
};
const build = {
name: "@build",
triggers: tron.parallel(scripts),
clean: "dist",
};
tron.task(scripts);
tron.task(build).addCleaner().addWatcher();You can inspect the generated task list with:
npx gulp --tasksOutput:
Tasks for ./gulpfile.js
├── scripts
├── @build
├── @clean
└── @watchCore concepts
Tron
The tron instance manages tasks and builds dependency trees.
import tron from "gulp-tron";
tron.task({
name: "build",
src: "src/**/*.js",
dest: "dist",
build: (bs) => bs.src().dest(),
});TaskConfig
A task is generally described as a TaskConfig object:
const conf = {
name: "scripts",
src: "src/**/*.js",
dest: "dist/js",
build: (bs) => bs.src().dest(),
dependsOn: ["shared"],
triggers: ["notify"],
};BuildStream
A BuildStream instance is created for each task execution and provides fluent API such as:
src()/add()/remove()/filter()rename()/order()/changed()copy()/del()/clean()/exec()dest()/reload()/debug()/pipe()
API overview
Tron methods
task()— register a task by config or namecreateTasks()— register multiple tasksaddCleaner()— create an auto-generated@cleantaskaddWatcher()— create an auto-generated@watchtaskseries()/parallel()— build task groupsselectTasks()/selectTasksAll()/findTask()— task lookup helpers
BuildStream methods
src(),add(),remove(),filter(),rename(),order()changed(),copy(),del(),clean(),exec()dest(),reload(),clear(),clone()promise(),chain(),pipe(),debug(),through()sync(),finish(),log()
Cleaner and watcher patterns
tron
.task({
name: "styles",
src: "src/**/*.scss",
dest: "dist/css",
build: (bs) => bs.src().pipe(/* sass plugin */).dest(),
clean: "dist/css",
watch: "src/**/*.scss",
})
.addCleaner()
.addWatcher({
browserSync: { server: "dist" },
});This creates:
stylestask@cleantask from the task'scleanproperty@watchtask from the task'swatchorsrcproperty
Related docs
License
MIT
