-
-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathgulpfile.js
More file actions
70 lines (61 loc) · 1.91 KB
/
Copy pathgulpfile.js
File metadata and controls
70 lines (61 loc) · 1.91 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
const {series, watch, src, dest, parallel} = require('gulp');
const pump = require('pump');
// gulp plugins and utils
const livereload = require('gulp-livereload');
const sass = require('gulp-sass')(require('sass'));
const zip = require('gulp-zip').default;
const beeper = require('beeper');
function serve(done) {
livereload.listen();
done();
}
const handleError = (done) => {
return function (err) {
if (err) {
beeper();
}
return done(err);
};
};
function hbs(done) {
pump([
src(['*.hbs', 'partials/**/*.hbs', '!node_modules/**/*.hbs']),
livereload()
], handleError(done));
}
function css(done) {
pump([
src('./assets/main/sass/*.scss', {sourcemaps: true}),
sass({style: 'compressed'}).on('error', sass.logError),
dest('assets/main/css', {sourcemaps: './'}),
livereload()
], handleError(done));
}
function zipper(done) {
const targetDir = 'dist/';
const themeName = require('./package.json').name;
const filename = themeName + '.zip';
pump([
// encoding: false keeps binary assets (fonts, images) as buffers; gulp 5 /
// vinyl-fs 4 otherwise decode files as UTF-8 and corrupt them in the zip.
src([
'**',
'!node_modules', '!node_modules/**',
'!dist', '!dist/**',
'!pnpm-lock.yaml',
'!pnpm-workspace.yaml',
'!AGENTS.md',
'!CLAUDE.md',
], {encoding: false}),
zip(filename),
dest(targetDir)
], handleError(done));
}
const cssWatcher = () => watch('./assets/main/sass/**/**', css);
const hbsWatcher = () => watch(['*.hbs', 'partials/**/*.hbs', '!node_modules/**/*.hbs'], hbs);
const watcher = parallel(cssWatcher, hbsWatcher);
const build = series(css);
const dev = series(build, serve, watcher);
exports.build = build;
exports.zip = series(build, zipper);
exports.default = dev;