-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (54 loc) · 1.6 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 gulp = require('gulp');
const pug = require('gulp-pug');
const sass = require('gulp-sass');
const server = require('gulp-server-livereload');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const imagemin = require('gulp-imagemin')
// Server function
gulp.task('server', done=>{
gulp.src('./dist')
.pipe(server({
livereload: true,
}));
done();
});
// Compress pug files
gulp.task('pug', done=>{
gulp.src('./src/index.pug')
.pipe(pug({pretty: true}))
.pipe(gulp.dest('./dist'));
done();
});
// Compress sass files
gulp.task('sass', done=>{
gulp.src('./src/styles/**/*.sass')
.pipe(sass({outputStyle: 'compressed'}))
.pipe(gulp.dest('./dist/assets/css'));
done();
});
// Compress js files
gulp.task('js', done=>{
gulp.src('./src/scripts/**/*.js')
.pipe(concat('main.js'))
//.pipe(uglify())
.pipe(gulp.dest('./dist/assets/js'));
done();
});
// Compress images
gulp.task('imagemin', done=>{
gulp.src('./src/images/**/*.*')
.pipe(imagemin())
.pipe(gulp.dest('dist/assets/images'));
done();
});
// Watch tasks
gulp.task('watch', done=>{
gulp.watch('./src/index.pug', gulp.parallel('pug'));
gulp.watch('./src/styles/**/*.sass', gulp.parallel('sass'));
gulp.watch('./src/scripts/**/*.js', gulp.parallel('js'));
gulp.watch('./src/images/**/*.*', gulp.parallel('imagemin'));
done();
});
// Default command
gulp.task('default', gulp.series('pug', 'sass', 'js', 'imagemin', 'server', 'watch', done=>{done();}));