-
Notifications
You must be signed in to change notification settings - Fork 175
/
gulpfile.js
80 lines (66 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
74
75
76
77
78
79
80
const gulp = require('gulp');
const autoprefixer = require('gulp-autoprefixer');
const clean = require('gulp-clean');
const concat = require('gulp-concat');
const runSequence = require('run-sequence');
const browserSync = require('browser-sync').create();
const distDirectory = 'dist';
const htmlBlob = 'src/*.html';
const imagesBlob = 'src/images/**';
const fontsBlob = 'src/fonts/**';
const stylesBlob = 'src/css/**';
gulp.task('default', function () {
return runSequence('build', 'serve');
});
gulp.task('build', function () {
return runSequence(
'cleanDist',
['processStyles', 'processHtml', 'processImages', 'processFonts']
);
});
gulp.task('serve', function () {
browserSync.init({
server: {
baseDir: distDirectory
}
});
gulp.watch(htmlBlob, function () {
return runSequence('processHtml', 'reloadBrowser');
});
gulp.watch(imagesBlob, function () {
return runSequence('processImages', 'reloadBrowser');
});
gulp.watch(fontsBlob, function () {
return runSequence('processFonts', 'reloadBrowser');
});
gulp.watch(stylesBlob, function () {
return runSequence('processStyles', 'reloadBrowser');
});
});
gulp.task('cleanDist', function () {
return gulp.src(distDirectory, {read: false, allowEmpty: true}).pipe(clean());
});
gulp.task('processHtml', function () {
return gulp.src(htmlBlob)
.pipe(gulp.dest(distDirectory));
});
gulp.task('processImages', function () {
return gulp.src(imagesBlob)
.pipe(gulp.dest(`${distDirectory}/images/`));
});
gulp.task('processFonts', function () {
return gulp.src(fontsBlob)
.pipe(gulp.dest(`${distDirectory}/fonts/`));
});
gulp.task('processStyles', function () {
return gulp.src(stylesBlob)
.pipe(concat('styles.css'))
.pipe(autoprefixer({
browsers: ['last 2 versions']
}))
.pipe(gulp.dest(`${distDirectory}/css`));
});
gulp.task('reloadBrowser', function (done) {
browserSync.reload();
done();
});