Skip to content

Instantly share code, notes, and snippets.

@cybersiddhu
Forked from rw3iss/launch.js
Created February 18, 2021 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cybersiddhu/95a855dd6e2dc9edc7da4482e2d6fcd9 to your computer and use it in GitHub Desktop.
Save cybersiddhu/95a855dd6e2dc9edc7da4482e2d6fcd9 to your computer and use it in GitHub Desktop.
browsersync script to hot reload any client project
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