-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
47 lines (37 loc) · 1.23 KB
/
Copy pathgulpfile.js
File metadata and controls
47 lines (37 loc) · 1.23 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
const gulp = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const browserSync = require('browser-sync').create();
function styles() {
return gulp.src('./scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./dist/css'))
.pipe(browserSync.stream());
}
function code() {
return gulp.src("./src/js/**/*.js")
.pipe(gulp.dest('./dist/js'));
}
function staticFiles() {
return gulp.src("./src/static/**/*", { encoding: false })
.pipe(gulp.dest('./dist/static'));
}
function html() {
return gulp.src("./src/**/*.html")
.pipe(gulp.dest("./dist"));
}
const build = gulp.parallel(styles, html, code, staticFiles);
function watch(done) {
browserSync.init({
server: {
baseDir: './dist'
}
});
gulp.watch('./scss/**/*.scss', styles);
gulp.watch('./src/**/*.html').on('change', gulp.series(html, browserSync.reload));
gulp.watch('./src/js/**/*.js').on('change', gulp.series(code, browserSync.reload));
gulp.watch('./src/static/**/*').on('change', gulp.series(staticFiles, browserSync.reload));
done();
}
exports.build = build;
exports.watch = gulp.series(build, watch);
exports.default = exports.watch;