This repository has been archived by the owner on Apr 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
70 lines (60 loc) · 2.06 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
var gulp = require('gulp'),
rename = require('gulp-rename'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
notify = require('gulp-notify'),
gutil = require('gulp-util'),
sassLint = require('gulp-sass-lint'),
minifycss = require('gulp-minify-css'),
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('build - Generate css and docs');
console.log('watch - Watch sass files and generate unminified css');
console.log('test - Lints Sass');
});
gulp.task('sasslint', function() {
return gulp.src('scss/**/*.s+(a|c)ss')
.pipe(sassLint())
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
});
var sassImportPaths = ['node_modules'];
gulp.task('sass', function() {
return gulp.src('scss/**/*.scss')
.pipe(sass({
style: 'expanded',
onError: throwSassError,
includePaths: sassImportPaths
}))
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1'))
.pipe(gulp.dest('build/css/'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('build/css/'));
});
gulp.task('build', ['sasslint', 'sass']);
gulp.task('sass-lite', function() {
return gulp.src('scss/build.scss')
.pipe(sass({ style: 'expanded', errLogToConsole: true, includePaths: sassImportPaths }))
.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']);