-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
51 lines (44 loc) · 1.39 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
var gulp = require('gulp');
var less = require('gulp-less');
var csscomb = require('gulp-csscomb');
var uncss = require('gulp-uncss');
var cleanCSS = require('gulp-clean-css');
// Compiling the CSS from less
gulp.task('less', function () {
return gulp.src('./assets/less/theme.less')
.pipe(less())
.pipe(gulp.dest('./assets/css/big'));
});
gulp.task('less-dev', function () {
return gulp.src('./assets/less/theme.less')
.pipe(less())
.pipe(gulp.dest('./assets/css'));
});
// Sorting the CSS
gulp.task('styles', ['less'], function () {
return gulp.src('./assets/css/big/theme.css')
.pipe(csscomb())
.pipe(gulp.dest('./assets/css/combed'));
});
// Removing unused classes in CSS
gulp.task('uncss', ['styles'], function () {
return gulp.src('./assets/css/combed/theme.css')
.pipe(uncss({
html: ['./docs/*.html'],
ignore: [/fp/],
timeout: 1000
}))
.pipe(gulp.dest('./assets/css/uncss/'));
});
// Removing tabs and spaces in CSS
gulp.task('minify-css', ['uncss'], function () {
return gulp.src('assets/css/uncss/theme.css')
.pipe(cleanCSS({ compatibility: 'ie8' }))
.pipe(gulp.dest('assets/css/'));
});
// Run all the tasks above in the following fixed sequence
gulp.task('css-prod', ['less', 'styles', 'uncss', 'minify-css']);
gulp.task('css-dev', ['less-dev']);
gulp.task('default', function () {
gulp.watch('./assets/less/*.less', ['css-dev']);
});