-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
78 lines (72 loc) · 1.96 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*jshint esversion: 6 */
// sudo npm i gulp-cli
var gulp = require('gulp');
var htmlmin = require('gulp-htmlmin');
// var csso = require('gulp-csso');
let cleanCSS = require('gulp-clean-css');
// const minify = require('gulp-minify');
var runSequence = require('run-sequence');
var uglify = require('gulp-uglify');
var pump = require('pump');
// var smushit = require('gulp-smushit');
gulp.task('sayhello', function() {
console.log('Hello');
});
// Gulp task to minify HTML files
gulp.task('minifyhtml', function() {
return gulp.src(['./index.html','./form.html'])
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
.pipe(gulp.dest('./build/'));
});
// Gulp task to minify CSS files
// gulp.task('minifycss', function() {
// return gulp.src('./css/*.css')
// // Minify the file
// .pipe(csso())
// // Output
// .pipe(gulp.dest('./build/css/'));
// });
gulp.task('minifycss', () => {
return gulp.src('./css/*.css')
.pipe(cleanCSS({compatibility: '*'}))
.pipe(gulp.dest('./build/css/'));
});
// Gulp task to minify JavaScript files
// gulp.task('minifyjs', function() {
// return gulp.src('./script.js')
// // Minify the file
// .pipe(uglify())
// // Output
// .pipe(gulp.dest('./build'));
// gulp.task('minifyjs', function(done) {
// gulp.src('./js/script.js')
// .pipe(minify())
// .pipe(gulp.dest('./build/js/'))
// done();
// });
gulp.task('minifyjs', function (cb) {
pump([
gulp.src('./js/script.js'),
uglify(),
gulp.dest('./build/js/')
],
cb
);
});
// //Optimizing images
// gulp.task('minifyimg', function () {
// return gulp.src('./img/*.{jpg,png}')
// .pipe(smushit())
// .pipe(gulp.dest('./build/img'));
// });
// Gulp task to minify all files
gulp.task('rockit', function () {
runSequence(
'minifyhtml',
'minifycss',
'minifyjs'
);
});