-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·65 lines (53 loc) · 1.68 KB
/
gulpfile.js
File metadata and controls
executable file
·65 lines (53 loc) · 1.68 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
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";
// Debounced task runner to prevent multiple rapid executions
let taskTimeouts = {};
function debounce(taskName, task, delay = 300) {
return () => {
clearTimeout(taskTimeouts[taskName]);
taskTimeouts[taskName] = setTimeout(task, delay);
};
}
// Enhanced watcher with debouncing
const watcher = () => {
// Watch JavaScript files
gulpWatch(
`${config.source}/_javascript/**/*.js`,
{ ignoreInitial: true },
debounce("scripts", scripts, 500),
);
// Watch image files with longer debounce due to processing time
gulpWatch(
`${config.source}/_images/**/*`,
{ ignoreInitial: true },
debounce("images", images, 1000),
);
// Watch SCSS files
gulpWatch(
`${config.source}/_styles/**/*.scss`,
{ ignoreInitial: true },
debounce("styles", styles, 300),
);
console.log("👀 Watching for changes...");
};
// Optimized build sequences
export default series(
parallel(images, styles, scripts), // Assets that can be built in parallel
parallel(data, sw), // Post-processing tasks
);
// Development watcher
export const watch = watcher;
// Pre-build (before Eleventy) - optimized order
export const prebuild = parallel(scripts, images, styles);
// Post-build (after Eleventy)
export const postbuild = parallel(data, sw);
// Fast rebuild (skip unchanged files) - useful for development
export const quick = parallel(scripts, styles);