-
Notifications
You must be signed in to change notification settings - Fork 12
/
gulpfile.js
89 lines (79 loc) · 2.22 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
/*!
* Gulp SMPL Layout Builder
*
* @version 8.3.3 (lite)
* @author Artem Dordzhiev (Draft) | Cuberto
* @type Module gulp
* @license The MIT License (MIT)
*/
/* Get plugins */
const gulp = require('gulp');
const browserSync = require('browser-sync');
const plumber = require('gulp-plumber');
const pug = require('gulp-pug');
const sass = require('gulp-sass')(require('sass'));
const autoprefixer = require('gulp-autoprefixer');
const del = require('del');
const webpack = require('webpack-stream');
/* Primary tasks */
gulp.task('default', (done) => {
gulp.series('serve')(done)
});
gulp.task('serve', (done) => {
gulp.series('clean', gulp.parallel('pug', 'sass', 'js'), 'browsersync', 'watch')(done)
});
/* Pug task */
gulp.task('pug', () => {
return gulp.src(['./src/pug/**/*.pug', '!./src/pug/_includes/**/*'])
.pipe(plumber())
.pipe(pug({
pretty: true,
basedir: "./src/pug/"
}))
.pipe(gulp.dest('./tmp/')).on('end', () => {
browserSync.reload();
});
});
/* Sass task */
gulp.task('sass', () => {
return gulp.src('./src/scss/main.scss')
.pipe(sass({
"includePaths": "node_modules"
}))
.pipe(autoprefixer())
.pipe(gulp.dest('./tmp/assets/css/'))
.pipe(browserSync.stream({match: '**/*.css'}));
});
/* JS (webpack) task */
gulp.task('js', () => {
return gulp.src(['./src/js/**/*'])
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('./tmp/assets/js'));
});
/* Browsersync Server */
gulp.task('browsersync', (done) => {
browserSync.init({
server: ["./tmp", "./src/static"],
notify: false,
ui: false,
online: false,
ghostMode: {
clicks: false,
forms: false,
scroll: false
}
});
done();
});
/* Watcher */
gulp.task('watch', () => {
global.isWatching = true;
gulp.watch("./src/scss/**/*.scss", gulp.series('sass'));
gulp.watch("./src/pug/**/*.pug", gulp.series('pug'));
gulp.watch("./src/js/**/*.*", gulp.series('js'));
gulp.watch("./config.json", gulp.parallel('pug', 'js'));
});
/* FS tasks */
gulp.task('clean', () => {
return del(['./tmp/**/*'], {dot: true});
});