-
Notifications
You must be signed in to change notification settings - Fork 40
/
gulpfile.js
134 lines (122 loc) · 3.74 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
var gulp = require('gulp');
var sass = require('gulp-sass');
var gstylus = require('gulp-stylus');
var rename = require('gulp-rename');
var cssmin = require('gulp-minify-css');
var prefix = require('gulp-autoprefixer');
var size = require('gulp-size');
var uncss = require('gulp-uncss');
var header = require('gulp-header');
var gutil = require('gulp-util');
var rework = require('gulp-rework');
var grid = require('rework-flex-grid');
var replace = require('gulp-replace');
var clean = require('gulp-clean');
var a11y = require('a11y');
var postcss = require('gulp-postcss');
var lint = require('stylelint');
var pkg = require('./package.json');
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @author <%= pkg.author %>',
' * @version v<%= pkg.version %>',
' * @link <%= pkg.homepage %>',
' * @license <%= pkg.license %>',
' */\n\n'].join('\n');
gulp.task('scss', ['scss:lint'], function() {
return gulp.src('scss/all.scss')
.pipe(sass())
.pipe(size({ gzip: true, showFiles: true }))
.pipe(prefix("last 2 versions"))
.pipe(rename('furtive.css'))
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest('css'))
.pipe(cssmin({ keepSpecialComments: 0 }))
.pipe(size({ gzip: true, showFiles: true }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('css'));
});
gulp.task('scss:lint', function() {
gulp.src(['scss/*.scss', '!scss/_normalize.scss'])
.pipe(postcss([lint()]))
});
gulp.task('stylus', function() {
return gulp.src('stylus/all.styl')
.pipe(gstylus())
.pipe(size({ gzip: true, showFiles: true }))
.pipe(prefix("last 2 versions"))
.pipe(rename('furtive.css'))
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest('css'))
.pipe(cssmin({ keepSpecialComments: 0 }))
.pipe(size({ gzip: true, showFiles: true }))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('css'));
});
gulp.task('rework-grid', function() {
return gulp.src('scss/_grid.scss')
.pipe(replace(/\.*/, ''))
.pipe(clean())
.pipe(rework(
grid({
numColumns: 6,
classNames: {
grid: 'grd',
row: 'row',
col: 'col'
}
})
))
.pipe(gulp.dest('scss'));
});
gulp.task('rework-grid-styl', function() {
return gulp.src('stylus/_grid.styl')
.pipe(replace(/\.*/, ''))
.pipe(clean())
.pipe(rework(
grid({
numColumns: 6,
classNames: {
grid: 'grd',
row: 'row',
col: 'col'
}
})
))
.pipe(gulp.dest('stylus'));
});
gulp.task('uncss', function() {
return gulp.src('css/furtive.min.css')
.pipe(size({ gzip: true, showFiles: true }))
.pipe(uncss({ html: ['index.html'] }))
.pipe(rename('site/index.furtive.min.css'))
.pipe(cssmin())
.pipe(size({ gzip: true, showFiles: true }))
.pipe(gulp.dest('./'));
});
gulp.task('a11y', function() {
a11y('http://furtive.co', function(err, reports) {
if (err) {
gutil.log(gutil.colors.red('gulp a11y error: ' + err));
return;
}
reports.audit.forEach(function(report) {
if (report.result === 'FAIL') {
gutil.log(displaySeverity(report), gutil.colors.red(report.heading), report.elements);
}
});
});
});
function displaySeverity(report) {
if (report.severity == 'Severe') {
return gutil.colors.red('[' + report.severity + '] ');
} else if (report.severity == 'Warning') {
return gutil.colors.yellow('[' + report.severity + '] ');
} else {
return '[' + report.severity + '] ';
}
}
gulp.task('watch', function() {
gulp.watch(['scss/*.scss','stylus/*.styl'], ['scss','stylus']);
});
gulp.task('default', ['scss', 'stylus', 'watch']);