-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
94 lines (82 loc) · 2.13 KB
/
gulpfile.babel.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import gulp from 'gulp';
import browserSync from 'browser-sync';
const server = browserSync.create();
import sass from 'gulp-sass';
import nunjucks from 'gulp-nunjucks';
import babel from 'gulp-babel';
import minify from 'gulp-minify';
import rename from 'gulp-rename';
import del from 'del';
const paths = {
styles: {
src: 'src/styles/**/*.scss',
dest: 'assets/styles/',
},
scripts: {
src: 'src/scripts/**/*.js',
dest: 'assets/scripts/',
},
htmlFiles: {
src: 'src/**/*.nunjucks',
dest: 'assets/',
},
images: {
src: 'src/images/**/*',
dest: 'assets/images/',
},
fonts: {
src: 'src/fonts/**/*',
dest: 'assets/fonts/',
},
};
export function styles() {
return gulp.src(paths.styles.src)
.pipe(sass())
.pipe(minify())
.pipe(gulp.dest(paths.styles.dest));
}
export function scripts() {
return gulp.src(paths.scripts.src)
.pipe(babel())
.pipe(gulp.dest(paths.scripts.dest));
}
export function htmlFiles() {
return gulp.src(paths.htmlFiles.src)
.pipe(nunjucks.compile())
.pipe(rename({
extname: '.html'
}))
.pipe(gulp.dest(paths.htmlFiles.dest));
}
export function images(){
return gulp.src(paths.images.src)
.pipe(gulp.dest(paths.images.dest));
}
export function fonts(){
return gulp.src(paths.fonts.src)
.pipe(gulp.dest(paths.fonts.dest));
}
function reload(done) {
server.reload();
done();
}
function serve(done) {
server.init({
server: {
baseDir: './assets/'
}
});
done();
}
export function clear(){
return del(['assets']);
}
export function watch() {
gulp.watch(paths.scripts.src, gulp.series(scripts, reload));
gulp.watch(paths.styles.src, gulp.series(styles, reload));
gulp.watch(paths.htmlFiles.src, gulp.series(htmlFiles, reload));
gulp.watch(paths.images.src, gulp.series(images, reload));
gulp.watch(paths.fonts.src, gulp.series(fonts, reload));
}
const build = gulp.series(clear, gulp.parallel(styles, scripts, htmlFiles, images, fonts), serve, watch);
export default build;