-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (49 loc) · 1.23 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
/**
* 自动化工具 gulp 脚本
*/
var gulp = require('gulp');
var debug = require('gulp-debug');
var browserSync = require('browser-sync').create();
gulp.task('server', function() {
browserSync.init({
server: {
baseDir: './'
}
});
gulp.watch('*.html').on('change', browserSync.reload);
gulp.watch('./src/less/**', ['less']);
});
gulp.task('less', function() {
logInfo('** less compile **');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var cleanCSS = require('gulp-clean-css');
var srcFile = 'index.less';
return gulp.src('./src/less/' + srcFile)
.pipe(debug({
title: '** less input >> '
}))
.pipe(less())
.pipe(autoprefixer({
browser: ['not ie <= 8']
}))
.pipe(cleanCSS({
compatibility: '*',
}))
.pipe(gulp.dest('./dist/css/'))
.pipe(debug({
title: '** less output << '
}))
.pipe(browserSync.stream());
});
/**
* logInfo - 格式化输出
*
* @param {string} str 待输出的字符串
* @return {null}
*/
function logInfo(str) {
if (str) {
console.log('\n\n\t' + str + '\n\n');
}
}