-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
executable file
·72 lines (62 loc) · 1.54 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
const fs = require('fs');
const path = require('path');
const sass = require('node-sass');
const gulp = require('gulp'); // eslint-disable-line
const mkdirp = require('mkdirp');
const jsonImporter = require('node-sass-json-importer');
const styleguide = require('@odopod/style-guide');
// Configure style guide
styleguide.configure({
name: 'Odo Sassplate',
client: 'Odopod',
jsonSource: 'extensions',
templatePath: path.resolve('style-guide-templates'),
themeColor: '#ff4843',
stylesheets: [
'styles.css',
'css/docs.css',
],
dist: {
markup: path.join(process.cwd(), 'dist'),
},
});
function compile(done) {
function logError(err, done) {
console.error(err.message); // eslint-disable-line no-console
console.log(err.file, 'on line', err.line); // eslint-disable-line no-console
done(err);
}
sass.render({
file: 'styles.scss',
importer: jsonImporter,
}, (err, result) => {
if (err) {
logError(err, done);
return;
}
mkdirp('dist', (err) => {
if (err) {
logError(err, done);
return;
}
fs.writeFile('dist/styles.css', result.css, (err) => {
if (err) {
logError(err, done);
return;
}
done();
});
});
});
}
function watcher() {
gulp.watch([
'styles.scss',
'components/*.scss',
'global-rules/*.scss',
'extensions/*.{scss,json}',
], compile);
}
gulp.task('compile', compile);
gulp.task('watch', gulp.series(compile, watcher));
gulp.task('default', gulp.parallel(compile, 'style-guide'));