forked from cms/tibi-svelte-starter
browsersync
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user