-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
51 lines (33 loc) · 1.46 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const { series, parallel, watch } = require('gulp');
// Pull in each task
const clean = require('./gulp-tasks/clean.js');
const styles = require('./gulp-tasks/styles.js');
const scripts = require('./gulp-tasks/scripts.js');
const images = require('./gulp-tasks/images.js');
const html = require('./gulp-tasks/html.js');
const validator = require('./gulp-tasks/html-validator.js');
// Set each directory and contents that we want to watch and assign the relevant task. `ignoreInitial` set to true will prevent the task being run when we run `gulp watch`, but it will run when a file changes
const watcher = () => {
watch([
'./components/**/*.scss',
'./src/assets/styles/**/*.scss'
], { ignoreInitial: true }, styles);
watch([
'./components/**/*.js',
'./src/assets/scripts/**/*.js'
], { ignoreInitial: true }, scripts);
};
// Minify HTML
exports.minify = series(html);
// Clean public folder
exports.clean = series(clean);
// Run validation tests
exports.validator = series(validator);
// Clean public folder then run each task in parallel
exports.build = series(clean, parallel(styles, scripts, images));
// Clean public folder then run each task in parallel
exports.dev = series(clean, parallel(styles, scripts, images), watcher);
// Run each task in parallel ready for production
exports.prod = parallel(styles, scripts, images, html);
// This is our watcher task that instructs gulp to watch directories and act accordingly
exports.watch = watcher;