-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (39 loc) · 1.27 KB
/
index.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
var gulp = require('gulp');
var less = require('gulp-less');
var merge = require('merge');
var sourcemaps = require('gulp-sourcemaps');
var prefixer = require('gulp-autoprefixer');
var minify = require('gulp-cssnano');
var concat = require('gulp-concat');
var rename = require("gulp-rename");
var plumber = require("gulp-plumber");
var notify = require("gulp-notify");
var lessFunctions = require("less-plugin-functions");
var lessGlob = require( "less-plugin-glob" );
module.exports = function( options ) {
var defaults = {
src: 'less/main.less',
dest: 'public/css',
name: 'main',
less: {
plugins: [ new lessFunctions, lessGlob ]
},
prefixer: { cascade: true }
}
// merge options with default values
options = merge.recursive( defaults, options );
// return task function
return function() {
return gulp.src( options.src )
.pipe( plumber( { errorHandler: notify.onError("Error: <%= error.message %>") } ) )
.pipe( sourcemaps.init() )
.pipe( less( options.less ) )
.pipe( prefixer( options.prefixer ) )
.pipe( concat( options.name + '.css') )
.pipe( sourcemaps.write() )
.pipe( gulp.dest( options.dest ) )
.pipe( minify() )
.pipe( rename( options.name + '.min.css' ) )
.pipe( gulp.dest( options.dest ) )
}
}