-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (45 loc) · 1.49 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
const autoprefixer = require('gulp-autoprefixer');
const concat = require('gulp-concat');
const connect = require('gulp-connect');
const gulp = require('gulp');
const livingcss = require('gulp-livingcss');
const sass = require('gulp-sass');
// Build the style guide
gulp.task('guide:build', ['css:dist'], () => {
const sourceFiles = './dist/*.css';
const destination = './docs';
setTimeout(() => {
gulp.src(sourceFiles)
.pipe(livingcss(destination, {
preprocess: (context, template, Handlebars) => {
context.title = 'Britannica Style Guide';
context.globalStylesheets.push('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css');
context.globalStylesheets.push('template-styles.css');
},
sortOrder: ['atoms', 'molecules', 'organisms', 'templates', 'pages'],
}))
.pipe(gulp.dest(destination));
}, 250);
});
// Build the CSS from our Sass
gulp.task('css:dist', () => {
gulp.src('./src/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(concat('britannica-styles.css'))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
}))
.pipe(gulp.dest('./dist'));
});
// Rebuild everything whenever changes to .scss files are made
gulp.task('watch', () => {
gulp.watch('./src/**/*.scss', ['guide:build']);
});
// Start local server, `Ctrl + C` to stop
gulp.task('server:start', () => {
connect.server({
livereload: true,
port: 3000,
root: 'docs',
});
});