-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
73 lines (54 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
72
73
// Dependencies
const config = require('./tools/gulp.config');
const gulp = require('gulp');
const del = require('del');
const fs = require('fs');
const browserSync = require('browser-sync');
//gulp css
require('./tools/css');
//gulp img
require('./tools/img');
// gulp html
require('./tools/html');
// gulp js
require('./tools/js');
// gulp ci:sri, ci:artefacts
require('./tools/ci');
const reload = done => {
browserSync.reload();
done();
};
const clean = () => del([`${config.paths.build}`, `${config.paths.artefacts}`], { force: true });
gulp.task('staticAssets', () =>
gulp
.src(`${config.paths.src.staticAssets}/**/*`)
.pipe(gulp.dest(`${config.paths.build}/${config.paths.assets}`))
);
gulp.task('robots', cb => {
fs.writeFile(`${config.paths.build}/robots.txt`, 'User-agent: *\nDisallow: /', cb);
});
// const sw = () => gulp.src(`${config.paths.src.js}/sw/*.*`)
// .pipe(gulp.dest(`${config.paths.public}`));
// // .pipe(gulp.dest(config.paths.dest[!!gulpUtil.env.production ? 'production' : 'development'].html));
function watch(reload) {
gulp.watch(`${config.paths.src.css}/**/*.scss`, gulp.series('css', reload));
gulp.watch(`${config.paths.src.js}/**/*`, gulp.series('js', reload));
gulp.watch(`${config.paths.src.img}/**/*`, gulp.series('img', reload));
gulp.watch(`${config.paths.src.html}/**/*`, gulp.series('html', reload));
}
const browserSyncConfig = {
notify: false,
// https: true,
server: [config.paths.build],
tunnel: false
};
function serve() {
browserSync(browserSyncConfig);
watch(reload);
}
gulp.task('ci', gulp.parallel('robots', 'ci:artefacts', 'ci:sri'));
gulp.task('assets', gulp.series('js', 'css', 'html', 'img', 'staticAssets'));
gulp.task('build', gulp.series(clean, 'assets'));
gulp.task('serve', gulp.series('build', serve));
gulp.task('compile', gulp.series('assets', 'ci'));
gulp.task('watch', gulp.series('build', watch));