-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
133 lines (122 loc) · 3.68 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
'use strict';
//=======================================================
// Include gulp
//=======================================================
var gulp = require('gulp');
//=======================================================
// Include Our Plugins
//=======================================================
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var sync = require('browser-sync');
var rename = require('gulp-rename');
var path = require('path');
var del = require('del');
var runSequence = require('run-sequence');
var kss = require('kss');
//=======================================================
// Compile Our Sass
//=======================================================
// Compile Sass
gulp.task('compile', function() {
return gulp.src('./src/{global,layout,components}/**/*.scss')
.pipe(sass({ outputStyle: 'nested' })
.on('error', sass.logError))
.pipe(prefix({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(rename(function (path) {
path.dirname = '';
return path;
}))
.pipe(gulp.dest('./dist/css'))
.pipe(sync.stream());
});
//=======================================================
// Generate style guide
//=======================================================
gulp.task('styleguide', function() {
return kss({
source: [
'src/global',
'src/components',
'src/layout'
],
destination: './dist/style-guide',
builder: 'src/style-guide/builder',
namespace: 'tacocat:' + __dirname + '/src/components/',
'extend-drupal8': true,
'verbose': true,
// The css and js paths are URLs, like '/misc/jquery.js'.
// The following paths are relative to the generated style guide.
css: [
path.relative(
__dirname + '/style-guide/',
__dirname + '/css/global.css'
),
path.relative(
__dirname + '/style-guide/',
__dirname + '/css/btn.css'
),
path.relative(
__dirname + '/style-guide/',
__dirname + '/css/teaser.css'
),
path.relative(
__dirname + '/style-guide/',
__dirname + '/css/l-center.css'
)
],
js: [
'../../src/components/teaser/teaser.js'
],
homepage: 'style-guide.md',
title: 'Style Guide'
});
});
//=======================================================
// Clean all directories.
//=======================================================
gulp.task('clean', ['clean:css', 'clean:styleguide']);
// Clean style guide files.
gulp.task('clean:styleguide', function () {
// You can use multiple globbing patterns as you would with `gulp.src`
return del([
'./dist/style-guide/*'
], {force: true});
});
// Clean CSS files.
gulp.task('clean:css', function () {
return del([
'./dist/css/*'
], {force: true});
});
//=======================================================
// Watch and recompile sass.
//=======================================================
gulp.task('watch', function() {
// Watch all my sass files and compile sass if a file changes.
gulp.watch(
'./src/{global,layout,components}/**/*.scss',
['lint:sass', 'compile:sass']
);
// Watch all my twig files and rebuild the style guide if a file changes.
gulp.watch(
'./src/{layout,components}/**/*.twig',
['styleguide']
);
});
//=======================================================
// Default Task
//
// runSequence runs 'clean' first, and when that finishes
// 'compile', 'styleguide' run at the same time.
//=======================================================
gulp.task('default', function(callback) {
runSequence(
'clean',
['compile', 'styleguide'],
callback
);
});