generated from htmlonelove/liga-accelerator-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (63 loc) · 1.92 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import gulp from 'gulp';
import browserSync from 'browser-sync';
import del from 'del';
import compileLayouts from './gulp/compileLayouts.mjs';
import compileStyles from './gulp/compileStyles.mjs';
import {copy, copyFavicons, copyImages, copySvg} from './gulp/copyAssets.mjs';
import js from './gulp/compileScripts.mjs';
import {
svgo,
sprite,
createWebp,
optimizeImages,
} from './gulp/optimizeImages.mjs';
import {
LintableFiles,
lintSpaces,
lintStyles,
lintScripts,
} from './gulp/lintSources.mjs';
const server = browserSync.create();
const streamStyles = () => compileStyles().pipe(server.stream());
const clean = () => del('build');
const syncServer = () => {
server.init({
server: 'build/',
index: 'sitemap.html',
notify: false,
open: true,
cors: true,
ui: false,
});
gulp.watch(LintableFiles.EDITORCONFIG, lintSpaces);
gulp.watch('source/**/*.html', gulp.series(copy, refresh));
gulp.watch(
['source/layouts/**/*.twig', 'source/data/**/*.js'],
gulp.series(compileLayouts, refresh)
);
gulp.watch(LintableFiles.STYLES, gulp.parallel(streamStyles, lintStyles));
gulp.watch(
LintableFiles.SCRIPTS,
gulp.parallel(gulp.series(js, refresh), lintScripts)
);
gulp.watch('source/img/**/*.svg', gulp.series(copySvg, sprite, refresh));
gulp.watch(
'source/img/**/*.{png,jpg,webp}',
gulp.series(copyImages, refresh)
);
gulp.watch('source/favicon/**', gulp.series(copy, refresh));
gulp.watch('source/{downloads,fonts,video}/**', gulp.series(copy, refresh));
gulp.watch('source/*.php', gulp.series(copy, refresh));
};
const refresh = (done) => {
server.reload();
done();
};
const build = gulp.series(
gulp.parallel(lintSpaces, lintStyles, lintScripts),
clean,
svgo,
gulp.parallel(copy, copyFavicons, compileLayouts, compileStyles, sprite, js)
);
const start = gulp.series(build, syncServer);
export {optimizeImages as imagemin, createWebp as webp, build, start};