-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.server.js
39 lines (37 loc) · 1.01 KB
/
gulpfile.server.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
const nameDeps = require('app-name')
const loadDeps = require('load-deps')
const camelCase = require('camelcase')
const stripDeps = ['gulp']
const renameFn = name => {
return camelCase(nameDeps(name, stripDeps))
}
const $ = loadDeps('*', {
renameKey: renameFn
})
const d = new Date()
const h = ('0' + d.getHours()).slice(-2)
const m = ('0' + d.getMinutes()).slice(-2)
const s = ('0' + d.getSeconds()).slice(-2)
const instant = '[' + `${h}:${m}:${s}`.grey + ']'
const server = {
create: ({path}) => {
$.browserSync.init({
server: {
baseDir: path
}
})
},
start: () => {
console.log(instant, 'BrowserSync'.bold.cyan)
console.log(instant, 'Starting development server... '.magenta)
return $.runSequence('start:watch', 'start:serve')
},
status: () => $.browserSync.active(),
reload: () => $.browserSync.reload(),
hot: () => {
if (server.status) {
server.reload()
}
}
}
module.exports = server