-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (45 loc) · 1.53 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
var gulp = require('gulp');
var cleanCSS = require('gulp-clean-css');
var concat = require('gulp-concat');
var pug = require('gulp-pug');
var purify = require('gulp-purifycss');
var rename = require('gulp-rename');
var server = require('gulp-develop-server');
var uglify = require('gulp-uglify');
gulp.task('minifyjs', function() {
return gulp.src('./resources/*.js')
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./dist'));
});
gulp.task('pre-uncss', gulp.series('minifyjs', function() {
return gulp.src('./resources/template.pug')
.pipe(pug({
doctype: 'html',
locals: {
pageTitle: 'Countdown',
anagram: '',
requireHead: false,
bestAnswers: ['tnetennba']
}
}))
.pipe(gulp.dest('./dist'));
}));
gulp.task('uncss', gulp.series('pre-uncss', function() {
return gulp.src(['./node_modules/bootstrap/dist/css/bootstrap.css', './resources/style.css'])
.pipe(purify(['./dist/template.html']))
.pipe(concat('style.min.css'))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('./public'));
}));
gulp.task('watch', function() {
gulp.watch(['./resources/**/*.pug', './resources/*.css', './resources/*.js'], gulp.series('build'));
});
gulp.task('server:start', function() {
server.listen( { path: './server.js' } );
});
gulp.task('server:restart', function() {
gulp.watch('./*.js', server.restart);
});
gulp.task('build', gulp.series('minifyjs', 'uncss'));
gulp.task('default', gulp.parallel('build', 'server:start', 'watch', 'server:restart'));