forked from getkirby/plainkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
99 lines (83 loc) · 2.57 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
// gulpfile.js
const gulp = require("gulp");
const browserSync = require("browser-sync");
const postcss = require("gulp-postcss");
const php = require('gulp-connect-php');
const minify = require('gulp-minify');
const paths = [
"site/**/*.php",
"site/**/*.css",
"site/**/*.js",
"tailwind.config.json",
"content/**/*.txt",
]
// -------------------------------------
// Task for compiling our CSS files using PostCSS
// -------------------------------------
gulp.task('postcss', function (cb) {
return gulp.src("./site/tailwind/*.css") // read .css files from ./src/ folder
.pipe(postcss()) // compile using postcss
.pipe(gulp.dest("./public/assets/css")) // paste them in ./assets/css folder
.pipe(browserSync.stream());
return cb();
});
// -------------------------------------
// Bundle JavaScript
// -------------------------------------
gulp.task('js-compress', function() {
return gulp.src('site/js/*.js')
.pipe(minify({
ext: {
// src:'-debug.js',
min:'.min.js'
},
noSource: true,
exclude: ['d3'],
ignoreFiles: ['d3.js', '-min.js']
}))
.pipe(gulp.dest('./public/assets/js/dist'))
});
// -------------------------------------
// Reloading in Browser
// -------------------------------------
gulp.task('reload', function (cb) {
browserSync.reload();
return cb();
});
// -------------------------------------
// PHP Server
// -------------------------------------
gulp.task('connect', function (done) {
php.server({
base: './public/',
keepalive: true,
port: 8989,
router: 'kirby/router.php',
}, function () {
browserSync({
proxy: '127.0.0.1:8989',
open: false,
notify: false,
});
});
gulp.watch(paths, { usePolling: true }, gulp.series(gulp.parallel('postcss', 'js-compress'), 'reload'))
return done();
});
gulp.task('disconnect', function(done) {
php.closeServer();
return done();
});
// -------------------------------------
// Task: clean
// -------------------------------------
gulp.task('clean', function () {
return del(paths.dist);
});
// -------------------------------------
// Task: default
// -------------------------------------
gulp.task('default', gulp.series(gulp.parallel('postcss', 'js-compress'), 'connect'));
// -------------------------------------
// Task: build
// -------------------------------------
gulp.task('build', gulp.series('clean', gulp.parallel('postcss', 'js-compress')));