-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (57 loc) · 1.67 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
var gulp = require('gulp'),
clean = require('gulp-clean'),
include = require('gulp-include'),
pug = require('gulp-pug'),
sass = require('gulp-sass'),
server = require('gulp-webserver'),
tildeImporter = require('node-sass-tilde-importer');
// Remove previous dist folder if exists
gulp.task('clean', function () {
return gulp.src('dist', {read: false, allowEmpty: true})
.pipe(clean());
});
// Compile pug templates into HTML
gulp.task('html', function () {
return gulp.src('src/templates/pages/*.pug')
.pipe(pug({
basedir: 'src/templates',
pretty: true
}))
.pipe(gulp.dest('dist'));
});
// Copy images to dist
gulp.task('images', function () {
return gulp.src('src/img/**/*')
.pipe(gulp.dest('dist/images'));
});
// Compile scss files into css
gulp.task('styles', function () {
return gulp.src('src/sass/style.scss')
.pipe(sass({importer: tildeImporter}))
.pipe(gulp.dest('dist/styles'));
});
// Compile js files
gulp.task('scripts', function () {
return gulp.src('src/js/*.js')
.pipe(include({
extensions: 'js',
hardFail: true,
includePaths: [
__dirname + '/node_modules',
__dirname + '/src/js'
]
}))
.pipe(gulp.dest('dist/scripts'));
});
// Run server from dist directory and open browser
gulp.task('server', function () {
gulp.src('dist').pipe(server({open: true}));
});
// Compile project by combining tasks above
gulp.task('build',
gulp.series(
'clean',
gulp.parallel('html', 'images', 'styles', 'scripts'), // Parallel tasks
'server'
)
);