This repository has been archived by the owner on Sep 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
114 lines (101 loc) · 2.9 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
const child = require('child_process');
const gulp = require('gulp');
const log = require('fancy-log');
const server = require('gulp-server-livereload');
const clean = require('gulp-clean');
const concat = require('gulp-concat');
const replace = require('gulp-replace');
DST = 'public';
ASSETS_SRC = 'assets';
ASSETS_DST = 'static/assets';
THEME = 'themes/govcert-ch';
THEME_ASSETS_SRC = THEME + '/src';
THEME_ASSETS_DST = THEME + '/static/assets';
gulp.task('hugo', () => {
log('[+] hugo dev');
const hugo = child.spawn('hugo', ['--config', 'config.yaml', '--buildDrafts', '--buildFuture']);
const hugologger = (buffer) => {
buffer
.toString()
.split(/\n/)
.forEach((message) => log('hugo: ' + message));
};
hugo.stdout.on('data', hugologger);
hugo.stderr.on('data', hugologger);
return hugo;
});
gulp.task('clean', () => {
log('[+] cleaning');
return gulp
.src([DST, THEME_ASSETS_DST], {
read: false,
allowEmpty: true,
})
.pipe(clean());
});
gulp.task('js', () => {
log('[+] js');
gulp
.src([
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/jquery-drilldown/dist/jquery.drilldown.min.js',
'node_modules/jquery/dist/jquery.min.js',
])
.pipe(gulp.dest(THEME_ASSETS_DST + '/js/'));
gulp
.src([THEME + '/src/js/highcharts/*.js'])
.pipe(gulp.dest(THEME_ASSETS_DST + '/js/highcharts/'));
return gulp
.src([
'node_modules/swiss-styleguide/src/assets/js/drilldown.js',
THEME + '/src/js/subnavigation.js',
])
.pipe(concat('styleguide.js'))
.pipe(gulp.dest(THEME_ASSETS_DST + '/js/'));
});
gulp.task('css', () => {
log('[+] css');
gulp
.src([THEME_ASSETS_SRC + '/css/opinion.css'])
.pipe(concat('opinion.css'))
.pipe(gulp.dest(THEME_ASSETS_DST + '/css/'));
return gulp
.src([
'node_modules/swiss-styleguide/build/css/{admin,print,vendors}.css',
THEME_ASSETS_SRC + '/css/custom.css',
])
.pipe(concat('main.css'))
.pipe(replace('font-family:', 'font-display:swap;font-family:'))
.pipe(gulp.dest(THEME_ASSETS_DST + '/css/'));
});
gulp.task('fonts', () => {
log('[+] fonts');
return gulp
.src(['node_modules/swiss-styleguide/build/fonts/*'])
.pipe(gulp.dest(THEME_ASSETS_DST + '/fonts'));
});
gulp.task('img', () => {
log('[+] imgs');
return gulp
.src(['node_modules/swiss-styleguide/build/img/*'])
.pipe(gulp.dest(THEME_ASSETS_DST + '/img'));
});
gulp.task('server', () => {
log('[+] serving');
gulp.src(DST).pipe(
server({
livereload: true,
directoryListing: false,
open: true,
}),
);
});
gulp.task('watch', () => {
log('[+] watching');
gulp.watch(
['content/**/*.html', 'content/**/*.md', 'themes/govcert-ch/**/*'],
gulp.series('hugo'),
);
});
gulp.task('build', gulp.series('css', 'fonts', 'img', 'js', 'hugo'));
gulp.task('default', gulp.series('build', gulp.parallel('server', 'watch')));