-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (72 loc) · 1.77 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
const gulp = require('gulp');
const pug = require('gulp-pug');
const del = require('del');
const sass = require('gulp-sass');
const rename = require('gulp-rename');
// Get all relevant paths
const SRC = '.';
const DEST = '..';
const paths = () => ({
templates: {
src: [`${SRC}/pug/**/*.pug`, `!${SRC}/pug/includes/*`],
dest: DEST,
},
css: {
src: [`${SRC}/sass/**/*.sass`],
dest: DEST,
},
php: {
src: [`${SRC}/php/*.php`],
dest: DEST,
},
static: {
src: [`${SRC}/static/**/*`],
dest: `${DEST}/static`
},
build: [`${DEST}/*.php`, `${DEST}/assets`],
});
// Compile the SASS and copy to build directory
function css (done) {
gulp.src(paths().css.src)
.pipe(sass().on('error', sass.logError))
// .pipe(rename((path) => path.basename = 'style'))
.pipe(gulp.dest(paths().css.dest));
done();
};
gulp.task(css);
// Render the pug templates
function templates (done) {
gulp.src(paths().templates.src)
.pipe(pug())
.pipe(rename((path) => path.extname = '.php'))
.pipe(gulp.dest(paths().templates.dest));
done();
};
gulp.task(templates);
// Copy the PHP source files to the destination
function php (done) {
gulp.src(paths().php.src)
.pipe(gulp.dest(paths().php.dest));
done();
};
gulp.task(php);
// Copy the static assets
function static (done) {
gulp.src(paths().static.src)
.pipe(gulp.dest(paths().static.dest));
done();
};
gulp.task(static);
// Wipe everything if necessary
gulp.task('clean', (done) => {
del(paths().build, {force: true});
done();
});
// automatic builds
gulp.task('watch', () => {
gulp.watch(paths().css.src, css);
gulp.watch(paths().templates.src, templates);
gulp.watch(paths().php.src, php);
});
// Build everything
gulp.task('default', gulp.parallel(css, templates, php, static));