What is a build system?
A build system is a collection of tasks (a.k.a. 'task runners') that automate repetitive work.
Why a task runner?
Common Tasks
Common Build Systems
Function:
Defines a task, its dependencies and the code it is to execute.
Dependencies must run before the task.
Tasks all run asynchronously
Syntax:
Example:
gulp.task(name, [dependencies], fn)
gulp.task('js', function() {
return gulp.src(['js/*.js'])
.pipe(concat('all.js'))
.pipe(minify())
.pipe(gulp.dest('dist/'));
});Function:
Takes a file system glob and emits files that match it
Glob - file pattern match for the source files you want to enter into the stream
Syntax:
Example:
gulp.src(glob, [options])gulp.task('js', function() {
return gulp.src(['js/*.js'], {base: 'js/'})
.pipe(concat('all.js'))
.pipe(minify())
.pipe(gulp.dest('dist/'));
});Function:
Syntax:
Example:
gulp.dest(folder, [options])gulp.task('js', function() {
return gulp.src(['js/*.js'], {base: 'js/'})
.pipe(concat('all.js'))
.pipe(minify())
.pipe(gulp.dest('dist/'));
});Function:
This function watches the files that match the glob pattern for changes and executes the task or callback specified as the last argument.
Syntax:
Example:
gulp.watch(glob, [options], [tasks] or callbacks)gulp.task('watch', function() {
gulp.watch(paths.scripts, ['lint']);
});