browsersync

This commit is contained in:
2021-09-14 13:26:35 +02:00
parent 95c2950193
commit 786fd12f34
6 changed files with 774 additions and 31 deletions

View File

@@ -38,6 +38,7 @@ async function build(catchError) {
log(`built in ${timerEnd - timerStart}ms.`)
}
let bs
switch (process.argv?.length > 2 ? process.argv[2] : "build") {
case "serve":
console.log("\x1b[36m%s\x1b[0mserving...")
@@ -46,6 +47,9 @@ switch (process.argv?.length > 2 ? process.argv[2] : "build") {
process.exit(1)
})
break
case "start":
bs = require("browser-sync")
bs.init(config.browserSync)
case "watch":
config.options.incremental = true
build(true)
@@ -53,7 +57,11 @@ switch (process.argv?.length > 2 ? process.argv[2] : "build") {
log("watching files...")
watcher.on("change", function (path) {
log(`${path} changed`, true)
build(true)
build(true).then(() => {
if (bs) {
bs.reload()
}
})
})
break
default: