UNPKG

838 BJavaScriptView Raw
1/**
2 * 处理样式任务
3 * @author lukezhu
4 * @date 2016-03-24
5 */
6
7module.exports = function(gulp, $, conf, browserSync) {
8 gulp.task('styles', function() {
9 var compress = conf.build.compress !== true ? !!conf.build.compress.css : true;
10 return gulp.src(conf.parsePwd(conf.styleFiles), { base: conf.parsePwd(conf.app) })
11 .pipe($.if(!conf.isProduction, $.sourcemaps.init()))
12 .pipe($.less()).on('error', conf.errorHandler('Less'))
13 .pipe($.autoprefixer()).on('error', conf.errorHandler('Autoprefixer'))
14 .pipe($.if(conf.isProduction && compress, $.cleanCss({compatibility: conf.build.compatibility})))
15 .pipe($.if(!conf.isProduction, $.sourcemaps.write()))
16 .pipe(gulp.dest(conf.parsePwd(conf.tmp)))
17 .pipe(browserSync.stream());
18 });
19}