-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
executable file
·66 lines (57 loc) · 1.6 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
'use strict';
const { src, dest, watch, parallel, series } = require('gulp');
const sass = require('gulp-sass')(require('sass'));
const postcss = require('gulp-postcss');
const cssnano = require('cssnano');
const autoprefixer = require('gulp-autoprefixer');
const rename = require('gulp-rename');
const terser = require('gulp-terser');
const browsersync = require('browser-sync');
const connect = require('gulp-connect-php');
// Sass Task
function scssTask() {
return src('./assets/sass/*.scss', { sourcemaps: true })
.pipe(sass())
.pipe(autoprefixer())
.pipe(rename({ suffix: '.min' }))
.pipe(postcss([cssnano()]))
.pipe(dest('./assets/css'))
};
// JavaScript Task
function jsTask() {
return src(
'./assets/disc/js/main.js', { sourcemaps: true })
.pipe(terser())
.pipe(dest('./assets/js', { sourcemaps: '.' }));
}
//Start Server
function browsersyncServe() {
return connect.server({
router: './kirby/router.php',
port: 8000,
keepalive: true,
debug: true
}, function() {
browsersync({
proxy: '127.0.0.1:8000',
notify: false,
})
});
}
//Reload Browser
function browsersyncReload(cb) {
browsersync.reload();
cb();
}
// Watch Task
function watchTask() {
watch(['./site/**/*.php', './site/**/*.yml'], browsersyncReload);
watch(['assets/sass/**/*.scss'], series(scssTask, browsersyncReload));
watch(['assets/sass/**/*.js'], series(jsTask, browsersyncReload));
}
exports.default = parallel(
scssTask,
jsTask,
browsersyncServe,
watchTask
);