-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
52 lines (45 loc) · 1.38 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
const gulp = require('gulp'),
htmlmin = require('gulp-htmlmin'),
uglify = require('gulp-uglify-es').default,
cleancss = require('gulp-clean-css'),
imagemin = require('gulp-imagemin'),
del = require('del'),
run_sequence = require('run-sequence');
/*minify all the HTML files*/
gulp.task('minify-html', () => {
gulp.src('./src/*.html')
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
.pipe(gulp.dest('./dist'));
});
/*minify all the CSS files*/
gulp.task('minify-css', () => {
gulp.src('./src/css/*.css')
.pipe(cleancss())
.pipe(gulp.dest('./dist/css'));
});
/*minify all the JS files*/
gulp.task('minify-js', () => {
gulp.src('./src/js/*.js')
.pipe(uglify())
.pipe(gulp.dest('./dist/js'));
});
/*optimize all the images*/
gulp.task('minify-image', () => {
gulp.src('./src/images/*.png')
.pipe(imagemin())
.pipe(gulp.dest('./dist/images'))
});
/*pipe all the audio files*/
gulp.task('pipe-audio', () => {
gulp.src('./src/audio/*.mp3')
.pipe(gulp.dest('./dist/audio'));
});
/*clean the destination folder before piping all the source files*/
gulp.task('clean', () => del(['dist']));
/*run the default task*/
gulp.task('default', ['clean'], () => {
run_sequence('minify-html', 'minify-css', 'minify-js', 'minify-image', 'pipe-audio');
});