Gulp Flashcards

1
Q

What are the 4 top level functions?

A

gulp. task
gulp. src
gulp. dest
gulp. watch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

gulp.task

A

One of four top level functions.

Defines your tasks. Its arguments are name, deps and fn.

gulp.task('mytask', function() {
  //do stuff
});
gulp.task('dependenttask', ['mytask'], function() {
  //do stuff after 'mytask' is done.
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Gulp?

A

Gulp is a streaming build system. It’s streaming nature is what allows it to pipe and pass around the data being manipulated or used by it’s plugins. The plugins are intended to only do one job each, so it’s not uncommon to pass a singular file through multiple plugins.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

deos

A

an array of task names

NOTE: deps is optional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

fn

A

the function that performs your task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

gulp.src

A

One of four top level functions

gulp.src points to the files we want to use. It’s parameters are globs and an optional options object. It uses .pipe for chaining it’s output into other plugins.

parameters are globs and an optional options objects. Uses .pipe for chaining its output into other plugins

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

globs

A

parameters of gulp.src

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

gulp.dest

A

One of four top level functions

gulp.dest points to the output folder we want to write files to.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Write code example of how to simply copy files with gulp

A
gulp.task('copyHtml', function() {
  // copy any html files in source/ to public/
  gulp.src('source/*.html').pipe(gulp.dest('public'));
});
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

gulp.watch

A

One of four top level functions.

gulp. watch like gulp.task has two main forms. Both of which return an EventEmitter that emits change events. The first of which takes a glob, an optional options object, and an array of tasks as it’s parameters.
gulp. watch(‘source/javascript/**/*.js’, [‘jshint’]);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the following code do:

gulp.watch(‘source/javascript/**/*.js’, [‘jshint’]);

A

when any files in the source/javascript subfolders that have an extension of .js change, then the task jshint will be run against those files.

The second form takes the glob, an optional options object, and an optional callback that will run when a change is picked up.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Write the syntax for creating a Gulp task.

A

gulp.task(‘NAME_OF_TASK’, function() {
gulp.src([‘PATH_TO_SOURCE_FILE’])
.pipe(INSERT_TASK)
.pipe(gulp.dest(‘PATH_TO_DESTINATION’);
});

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is –save-dev used for?

A

–save-dev is used to update dev-dependencies in package.json

e.g. npm install gulp –save-dev

How well did you know this?
1
Not at all
2
3
4
5
Perfectly