generated from Vo7kov/gulp-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
94 lines (75 loc) · 2.06 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
const { src, dest, parallel, series, watch } = require('gulp');
const browserSync = require('browser-sync').create();
const concat = require('gulp-concat');
const sass = require('gulp-sass')(require('sass'));
const autoprefixer = require('gulp-autoprefixer');
const imagemin = require('gulp-imagemin');
const newer = require('gulp-newer');
const del = require('del');
const ghPages = require('gulp-gh-pages');
function browsersync() {
browserSync.init({
server: { baseDir: 'src/' },
notify: false,
online: false,
});
}
function scripts() {
return src([
'src/scripts/main.js',
])
.pipe(concat('main.min.js'))
.pipe(dest('src/scripts/'))
.pipe(browserSync.stream())
}
function styles() {
return src([
'src/styles/main.scss',
])
.pipe(sass())
.pipe(concat('main.min.css'))
// eslint-disable-next-line max-len
.pipe(autoprefixer({ overrideBrowserslist: ['last 10 versions'], grid: true }))
.pipe(dest('src/css/'))
.pipe(browserSync.stream())
}
function images() {
return src('src/images/src/**/*')
.pipe(newer('src/images/dest/'))
.pipe(imagemin())
.pipe(dest('src/images/dest/'))
}
function cleanimg() {
return del('src/images/src/**/*', { force: true })
}
function cleandist() {
return del('dist/**/*', { force: true })
}
function buildcopy() {
return src([
'src/css/**/*.min.css',
'src/scripts/**/*.js',
'src/images/dest/**/*',
'src/**/*.html',
], { base: 'src' })
.pipe(dest('dist'));
}
function pages() {
return src('./dist/**/*')
.pipe(ghPages())
}
function startWatch() {
watch('src/styles/**/*', styles);
watch(['src/**/*.js', '!src/**/*.min.js'], scripts);
watch('src/**/*.html').on('change', browserSync.reload);
watch('src/images/src/**/*', images);
}
exports.browsersync = browsersync;
exports.scripts = scripts;
exports.styles = styles;
exports.images = images;
exports.cleanimg = cleanimg;
exports.cleandist = cleandist;
exports.pages = pages;
exports.build = series(cleandist, styles, scripts, images, buildcopy);
exports.default = parallel(scripts, styles, browsersync, startWatch);