-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (54 loc) · 1.64 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
var fs = require('fs');
var path = require('path');
var gulp = require('gulp');
var watch = require('gulp-watch');
var plumber = require('gulp-plumber');
var header = require('gulp-header');
var rename = require('gulp-rename');
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
var cleanCSS = require('gulp-clean-css');
// Globals
const pkg = JSON.parse(fs.readFileSync('package.json'));
const options = {
input : './client/assets/less/*.less',
output : './client/public/css',
suffix : '.min',
plumber : function(err){
if(!process.env.CI){
console.log(err);
this.emit('end');
};
},
clean : {
format:{
breaks:{
afterComment:true
}
}
},
header : [
'/*!',
' * <%= name %> v<%= version %> (<%= homepage %>)',
' * Copyright 2017-<%= new Date().getFullYear() %> <%= author %>',
' * Licensed under the <%= license %> (http://opensource.org/licenses/<%= license %>)',
' */',
'',''].join('\n'),
};
// Default, used by Travis CI
gulp.task('default', ['build-less']);
// Build tasks
gulp.task('build-less', function(){
return gulp.src(options.input)
.pipe(plumber(options.plumber))
.pipe(less())
.pipe(autoprefixer())
.pipe(cleanCSS(options.clean))
.pipe(header(options.header, pkg))
.pipe(rename({suffix: options.suffix}))
.pipe(gulp.dest(options.output));
});
// Watcher
gulp.task('watch', function () {
gulp.watch('./client/assets/less/**/*.less', ['build-less']);
});