-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
80 lines (62 loc) · 1.67 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
79
80
var gulp = require('gulp');
var debug = require('gulp-debug');
var autoprefixer = require('gulp-autoprefixer');
/**
* Compile less
*/
gulp.task('less', function(){
logInfo('** less compile **');
var less = require('gulp-less');
var minifyCss = require('gulp-minify-css');
var srcFile = './src/less/index.less';
var destFolder = './dist/css/';
return gulp.src(srcFile)
.pipe(debug({
title: '** less input >> '
}))
.pipe(less())
.pipe(autoprefixer({
// Browser param ref: https://github.com/ai/browserslist#queries
browser: ['not ie <= 8']
}))
.pipe(minifyCss())
.pipe(gulp.dest(destFolder))
.pipe(debug({
title: '** less output << '
}));
});
gulp.task('watch-less', function(){
logInfo('** watch-less **');
gulp.watch('./src/less/*', ['less']);
});
/**
* gulp - Uglify javascript
*/
gulp.task('uglify', function(){
var uglify = require('gulp-uglify');
var srcFile = './src/js/index.js';
return gulp.src(srcFile)
.pipe(debug({
title: '** uglify input >> '
}))
.pipe(uglify())
.pipe(gulp.dest('./dist/js/'))
.pipe(debug({
title: '** uglify output << '
}));
});
gulp.task('watch-js', function(){
logInfo('** watch-js **');
gulp.watch('./src/js/*', ['uglify']);
});
/**
* logInfo - Format console output
*
* @param {string} str String to output
* @return {null}
*/
function logInfo(str){
if(str){
console.log('\n\n\t' + str + '\n\n');
}
}