-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
95 lines (77 loc) · 2.4 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
'use strict';
var path = require('path');
var del = require('del');
var _ = require('lodash');
var sassdoc = require('sassdoc');
var respokeStyle = require('respoke-style');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var ROOT_PATH = __dirname;
var paths = {
output: path.join(ROOT_PATH, '.tmp'),
source: path.join(ROOT_PATH, 'style-guide'),
sass: path.join(ROOT_PATH, 'styles')
};
function cleanTask(done) {
del(paths.output, done);
}
function buildTask() {
var jadeFilter = $.filter('*.jade');
var sassFilter = $.filter('*.scss');
return gulp.src(path.join(paths.source, '**/*'))
.pipe(jadeFilter)
.pipe($.jade({
pretty: true,
locals: respokeStyle.templateLocals
}))
.pipe(jadeFilter.restore())
.pipe(sassFilter)
.pipe($.sourcemaps.init())
.pipe($.sass({
includePaths: respokeStyle.includeStylePaths()
}))
.pipe($.sourcemaps.write())
.pipe(sassFilter.restore())
.pipe(gulp.dest(paths.output));
}
function webserverTask() {
return gulp.src(paths.output)
.pipe($.webserver({
host: 'localhost',
port: '1236',
livereload: true
}));
}
function watchTask() {
gulp.watch([
path.join(paths.source, '**/*'),
path.join(respokeStyle.paths.assets, '**/*'),
path.join(respokeStyle.paths.styles, '**/*'),
path.join(respokeStyle.paths.templates, '**/*')
], ['style-guide:build', 'style-guide:copy-assets']);
}
function copyAssets() {
return gulp.src(path.join(respokeStyle.paths.assets, '**/*'))
.pipe(gulp.dest(paths.output));
}
function sassdocTask() {
return gulp.src(path.join(paths.sass, '**/*.scss'))
.pipe(sassdoc({
dest: 'sassdoc',
display: {
access: ['public']
}
}));
}
gulp.task('style-guide', [
'style-guide:build',
'style-guide:copy-assets',
'style-guide:webserver',
'style-guide:watch'
]);
gulp.task('style-guide:clean', cleanTask);
gulp.task('style-guide:build', ['style-guide:clean'], buildTask);
gulp.task('style-guide:copy-assets', ['style-guide:clean'], copyAssets);
gulp.task('style-guide:webserver', ['style-guide:build'], webserverTask);
gulp.task('style-guide:watch', watchTask);
gulp.task('sassdoc', sassdocTask);