-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
74 lines (64 loc) · 2.2 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
66
67
68
69
70
71
72
73
74
var gulp = require('gulp'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
notify = require('gulp-notify'),
gutil = require('gulp-util'),
scsslint = require('gulp-scss-lint'),
cleanCSS = require('gulp-clean-css');
sassdoc = require('sassdoc'),
util = require('util');
/* Helper functions */
function throwSassError(sassError) {
throw new gutil.PluginError({
plugin: 'sass',
message: util.format(
"Sass error: '%s' on line %s of %s",
sassError.message,
sassError.line,
sassError.file
)
});
}
/* Gulp instructions start here */
gulp.task('help', function() {
console.log('sass - Generate the min and unminified css from sass');
console.log('docs - Generate the docs from the source sass');
console.log('build - Generate css and docs');
console.log('watch - Watch sass files and generate unminified css');
console.log('test - Lints Sass');
});
gulp.task('sasslint', function() {
var path = (gutil.env.file)? gutil.env.file : '**/*.scss';
return gulp.src('scss/' + path)
.pipe(scsslint())
.pipe(scsslint.failReporter());
});
gulp.task('sass', function() {
return gulp.src('scss/**/*.scss')
.pipe(sass({
style: 'expanded',
onError: throwSassError
}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
.pipe(gulp.dest('build/css/'))
.pipe(rename({suffix: '.min'}))
.pipe(cleanCSS())
.pipe(gulp.dest('build/css/'));
});
gulp.task('docs', function() {
return gulp.src('scss/**/*.scss')
.pipe(sassdoc({ 'dest': 'build/docs'}));
});
gulp.task('build', ['sasslint', 'sass', 'docs']);
gulp.task('sass-lite', function() {
return gulp.src('scss/**/*.scss')
.pipe(sass({ style: 'expanded', errLogToConsole: true }))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
.pipe(gulp.dest('build/css/'));
});
gulp.task('watch', function() {
gulp.watch('scss/**/*.scss', ['sass-lite']);
});
gulp.task('test', ['sasslint']);
gulp.task('default', ['help']);