-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
41 lines (35 loc) · 1.17 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
const gulp = require('gulp'),
htmlmin = require('gulp-htmlmin'),
imagemin = require('gulp-imagemin'),
minifyCss = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
useref = require('gulp-useref'),
gulpif = require('gulp-if'),
del = require('del');
/* Clean build directory */
gulp.task('clean', function() {
return del(['build/**/*']);
});
/* Combine and minify scripts and stylesheets */
gulp.task('combine', function () {
return gulp.src('index.html')
.pipe(useref())
.pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', minifyCss()))
.pipe(useref({}))
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('build/'));
});
/* Copy all static images */
gulp.task('images', function() {
return gulp.src('images/**/*')
.pipe(imagemin({optimizationLevel: 5}))
.pipe(gulp.dest('build/images'));
});
/* Copy favicon to build directory */
gulp.task('copy-favicon', function() {
return gulp.src('favicon.*')
.pipe(gulp.dest('build/'));
});
/* Main build instruction */
gulp.task('build', gulp.series('combine', 'images', 'copy-favicon'));