generated from htmlonelove/liga-accelerator-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
46 lines (38 loc) · 1.71 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
import gulp from 'gulp';
import browserSync from 'browser-sync';
import del from 'del';
import styles from './gulp/compileStyles.mjs';
import { copy, copyImages, copySvg } from './gulp/copyAssets.mjs';
import js from './gulp/compileScripts.mjs';
import {optimizeSvg, sprite, createWebp, optimizePng, optimizeJpg} from './gulp/optimizeImages.mjs';
const server = browserSync.create();
const streamStyles = () => styles().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('source/**.html', gulp.series(copy, refresh));
gulp.watch('source/sass/**/*.{scss,sass}', streamStyles);
gulp.watch('source/js/**/*.{js,json}', gulp.series(js, refresh));
gulp.watch('source/data/**/*.{js,json}', gulp.series(copy, refresh));
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/video/**', gulp.series(copy, refresh));
gulp.watch('source/downloads/**', gulp.series(copy, refresh));
gulp.watch('source/*.php', gulp.series(copy, refresh));
};
const refresh = (done) => {
server.reload();
done();
};
const build = gulp.series(clean, copy, sprite, gulp.parallel(styles, js, optimizePng, optimizeJpg, optimizeSvg));
const dev = gulp.series(clean, copy, sprite, gulp.parallel(styles, js, optimizePng, optimizeJpg, optimizeSvg), syncServer);
const start = gulp.series(clean, copy, sprite, gulp.parallel(styles, js), syncServer);
export { createWebp as webp, build, start, dev};