-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
79 lines (66 loc) · 2 KB
/
Copy pathgulpfile.js
File metadata and controls
79 lines (66 loc) · 2 KB
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
79
// include gulp
var gulp = require('gulp');
// include plug-ins
var changed = require('gulp-changed');
var minifyHTML = require('gulp-minify-html');
var concat = require('gulp-concat');
var stripDebug = require('gulp-strip-debug');
var uglify = require('gulp-uglify');
var less = require('gulp-less');
var minifyCSS = require('gulp-minify-css');
var imagemin = require('gulp-imagemin');
var clip = require('gulp-clip-empty-files');
var lessSrc = './source/less/*.less';
//var outputDir './output';
gulp.task('manifest',function(){
gulp.src('./source/*.json')
.pipe(changed('./source/*.json'))
.pipe(minifyHTML())
.pipe(gulp.dest('./output'));
});
// minify new or changed HTML pages
gulp.task('htmlfiles', function() {
var htmlSrc = './source/html/*.html',
htmlDst = './output';
gulp.src(htmlSrc)
.pipe(changed(htmlDst))
.pipe(minifyHTML())
.pipe(gulp.dest(htmlDst));
});
// JS concat, strip debugging and minify
gulp.task('scripts', function() {
gulp.src('./source/js/*.js')
.pipe(stripDebug())
.pipe(uglify())
.pipe(gulp.dest('./output'));
});
gulp.task('less', function() {
gulp.src(lessSrc)
.pipe(changed(lessSrc))
//.pipe(foxy().transform())
.pipe(less())
.pipe(clip())
.pipe(gulp.dest('./output'));
});
gulp.task('minifyCSS',function(){
gulp.src('./output/*.css')
.pipe(minifyCSS())
.pipe(gulp.dest('./output'));
});
gulp.task('imagemin', function() {
var imgSrc = './source/img/*',
imgDst = './output';
gulp.src(imgSrc)
.pipe(changed(imgDst))
.pipe(imagemin())
.pipe(gulp.dest(imgDst));
});
gulp.task('default', ['manifest','htmlfiles','scripts','less','minifyCSS','imagemin'], function() {
// watch for HTML changes
gulp.watch('./source/html/*.html', ["htmlfiles"]);
gulp.watch('./source/js/*.js', ["scripts"]);
gulp.watch('./source/less/*.less', ["less"]);
gulp.watch('./source/img/*', ["imagemin"]);
gulp.watch('./source/*.json', ["manifest"]);
gulp.watch('./output/*.css', ["minifyCSS"]);
});