Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·70 lines (59 loc) · 1.7 KB
/
Copy pathgulpfile.js
File metadata and controls
executable file
·70 lines (59 loc) · 1.7 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import gulp from "gulp";
import config from "./_tasks/config.js";
const { parallel, series } = gulp;
const gulpWatch = gulp.watch;
// Pull in each task
import data from "./_tasks/data.js";
import images from "./_tasks/images.js";
import scripts from "./_tasks/scripts.js";
import sw from "./_tasks/serviceworker.js";
import styles from "./_tasks/styles.js";
// Enhanced watcher with debouncing
const watcher = () => {
// Watch JavaScript files
gulpWatch(
[
`${config.source}/_javascript/**/*.js`,
`!${config.source}/_javascript/serviceworker/**/*.js`,
],
{ ignoreInitial: true, delay: 500 },
scripts,
);
// Watch image files with longer debounce due to processing time
gulpWatch(
`${config.source}/_images/**/*`,
{ ignoreInitial: true, delay: 1000 },
images,
);
// Watch SCSS files
gulpWatch(
`${config.source}/_styles/**/*.{css,scss}`,
{ ignoreInitial: true, delay: 300 },
styles,
);
// Rebuild the service worker after its source or generated assets change
gulpWatch(
[
`${config.source}/_javascript/serviceworker/**/*.js`,
`${config.static}/c/**/*.css`,
`${config.static}/j/**/*.js`,
],
{ ignoreInitial: true, delay: 500 },
sw,
);
console.log("👀 Watching for changes...");
};
// Optimized build sequences
export default series(
styles,
parallel(images, scripts),
parallel(data, sw), // Post-processing tasks
);
// Development watcher
export const watch = watcher;
// Pre-build (before Eleventy) - optimized order
export const prebuild = series(styles, parallel(scripts, images));
// Post-build (after Eleventy)
export const postbuild = parallel(data, sw);
// Fast rebuild (skip unchanged files) - useful for development
export const quick = series(styles, scripts);