-
-
Save cybersiddhu/95a855dd6e2dc9edc7da4482e2d6fcd9 to your computer and use it in GitHub Desktop.
browsersync script to hot reload any client project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bs = require('browser-sync').create(); | |
// Config params (relative to where npm/script is called from): | |
const PORT = 3000; | |
const OUTPUT_DIR = './build'; | |
bs.watch(`${OUTPUT_DIR}/**/*.js`, function (event, file) { | |
bs.reload("*.js"); | |
}) | |
bs.watch(`${OUTPUT_DIR}/**/*.css`, function (event, file) { | |
if (event === "change") { | |
bs.reload("*.css"); | |
} | |
}) | |
bs.init({ | |
port: PORT, | |
server: OUTPUT_DIR, | |
serveStatic: [`${OUTPUT_DIR}/static/`], | |
//cors: true, | |
browser: "google chrome", // [ "google chrome", "firefox"] | |
open: "local", // false | |
reloadOnRestart: true, | |
ui: false, | |
notify: false | |
//scrollProportionally: false | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment