-
-
Notifications
You must be signed in to change notification settings - Fork 433
/
Copy pathgulpfile.js
110 lines (100 loc) · 3.88 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
const gulp = require('gulp');
const connect = require('gulp-connect');
const open = require('gulp-open');
const path = require('path');
const buildStyles = require('./build/build-styles');
const buildPages = require('./build/build-pages');
const buildScript = require('./build/build-script');
const buildSponsors = require('./build/build-sponsors');
const buildCoreDemos = require('./build/build-core-demos');
const buildSvelteDemos = require('./build/build-svelte-demos');
const buildVueDemos = require('./build/build-vue-demos');
const buildReactDemos = require('./build/build-react-demos');
/* ==================================================================
Build Styles
================================================================== */
gulp.task('less', buildStyles);
gulp.task('sponsors', buildSponsors);
gulp.task('pug', buildPages);
gulp.task('js', buildScript);
gulp.task('core-demos', buildCoreDemos.all);
gulp.task('svelte-demos', buildSvelteDemos.all);
gulp.task('vue-demos', buildVueDemos.all);
gulp.task('react-demos', buildReactDemos.all);
gulp.task('demos', gulp.series(['core-demos', 'svelte-demos', 'vue-demos', 'react-demos']));
gulp.task('build', gulp.series(['sponsors', 'less', 'js', 'pug', 'demos']));
/* =================================
Watch
================================= */
gulp.task('watch', () => {
gulp.watch('./src/js/**/*.*', gulp.series(['js']));
gulp.watch('./src/less/**/*.*', gulp.series(['less']));
gulp.watch('./src/pug/**/*.pug', { events: ['change'] }).on('change', (changedPath) => {
const sep = String(path.sep);
const filePath = changedPath.split(`src${sep}pug${sep}`)[1];
if (filePath.indexOf(`docs-demos${sep}svelte`) >= 0) return;
if (filePath.indexOf('_') === 0 || filePath.indexOf('_layout.pug') >= 0) {
return;
}
const src = [];
if (filePath.split(sep)[1] && filePath.split(sep)[1].indexOf('_') === 0) {
src.push(`${filePath.split(sep)[0]}${sep}*.pug`);
src.push(`!${filePath.split(sep)[0]}${sep}_*.pug`);
} else {
src.push(filePath);
}
const dest =
filePath.split(sep)[0] === filePath
? `.${sep}public${sep}`
: `.${sep}public${sep}${path.parse(filePath).dir}`;
buildPages(null, {
src,
dest,
});
});
gulp.watch('./src/pug/**/*.f7.html', { events: ['change'] }).on('change', (changedPath) => {
const sep = String(path.sep);
const name = changedPath
.split(`src${sep}pug${sep}docs-demos${sep}core${sep}`)[1]
.split('.f7.html')[0];
buildCoreDemos.one(name);
});
gulp.watch('./src/pug/**/*.svelte', { events: ['change'] }).on('change', (changedPath) => {
const sep = String(path.sep);
const name = changedPath
.split(`src${sep}pug${sep}docs-demos${sep}svelte${sep}`)[1]
.split('.svelte')[0];
buildSvelteDemos.one(name);
});
gulp.watch('./src/pug/**/*.vue', { events: ['change'] }).on('change', (changedPath) => {
const sep = String(path.sep);
const name = changedPath
.split(`src${sep}pug${sep}docs-demos${sep}vue${sep}`)[1]
.split('.vue')[0];
buildVueDemos.one(name);
});
gulp.watch('./src/pug/**/*.jsx', { events: ['change'] }).on('change', (changedPath) => {
const sep = String(path.sep);
const name = changedPath
.split(`src${sep}pug${sep}docs-demos${sep}react${sep}`)[1]
.split('.jsx')[0];
buildReactDemos.one(name);
});
});
/* =================================
Server
================================= */
gulp.task('connect', () => {
return connect.server({
root: ['./public/'],
livereload: true,
port: '3001',
});
});
gulp.task('open', () => {
return gulp.src('./public/index.html').pipe(open({ uri: 'http://localhost:3001/index.html' }));
});
// gulp.task('server', gulp.parallel(['watch', 'connect', 'open']));
gulp.task('server', gulp.parallel(['watch', 'connect']));
gulp.task('default', gulp.series(['server']));
gulp.task('test', gulp.series(['build']));