-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
63 lines (53 loc) · 1.5 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
const {src, dest, series, watch} = require('gulp');
const sass = require('gulp-sass');
const del = require('del');
const csso = require('gulp-csso');
const concat = require('gulp-concat');
const sync = require('browser-sync').create();
const htmlmin = require('gulp-htmlmin');
const include = require('gulp-file-include');
const autoprefixer = require('gulp-autoprefixer');
function html() {
return src('src/**.html')
.pipe(include({
prefix: '@@'
}))
.pipe(htmlmin({
collapseWhitespace: true
}))
.pipe(dest('built'))
}
function style() {
return src('src/sass/**.sass')
.pipe(sass())
.pipe(autoprefixer())
.pipe(csso())
.pipe(concat('style.min.css'))
.pipe(dest('built/css/'))
}
function img() {
return src('src/img/**/*.{png,jpg,jpeg,webp,raw}')
.pipe(dest('built/img'))
}
function script() {
return src('src/js/**.js')
.pipe(concat('scripts.min.js'))
.pipe(dest('built/js'))
}
function fonts() {
return src('src/fonts/**')
.pipe(dest('built/fonts'))
}
function clear() {
return del('built')
}
function serve() {
sync.init({
server: './built'
});
watch('src/js/**.js', series(script)).on('change', sync.reload)
watch('src/sass/**.sass', series(style)).on('change', sync.reload)
watch('src/**.html', series(html)).on('change', sync.reload);
}
exports.style = style
exports.default = series(clear, html, style, img, script, fonts, serve)