Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to live reload a node js app

const livereload = require("livereload");
const connectLivereload = require("connect-livereload");

// open livereload high port and start to watch public directory for changes
const liveReloadServer = livereload.createServer();
liveReloadServer.watch(path.join(__dirname, 'public'));

// ping browser on Express boot, once browser has reconnected and handshaken
liveReloadServer.server.once("connection", () => {
  setTimeout(() => {
    liveReloadServer.refresh("/");
  }, 100);
});

const app = express();

// monkey patch every served HTML so they know of changes
app.use(connectLivereload());
Comment

PREVIOUS NEXT
Code Example
Javascript :: alpine js x-on click not working 
Javascript :: set value of attribute using each and keyup jquery 
Javascript :: array 
Javascript :: reduce method in javascript 
Javascript :: moment.js get time from now 
Javascript :: environment variable to debug knex 
Javascript :: addition of time in javascript 
Javascript :: node http request 
Javascript :: sum function in javascript 
Javascript :: math module js 
Javascript :: how to add key value pair in object 
Javascript :: localhost server in react native 
Javascript :: multiple forms formData js 
Javascript :: node js install aws-sdk 
Javascript :: bootstrap and masonry 
Javascript :: ReactComponent 
Javascript :: mapStateProps 
Javascript :: one signal api to send notification 
Javascript :: sprintf js 
Javascript :: how to update mongodb collection with a new field 
Javascript :: login with facebook expo react native 
Javascript :: keep value after refresh javascript 
Javascript :: javascript array find case insensitive 
Javascript :: js setinterval run immediately 
Javascript :: js extract properties from object 
Javascript :: is loop backward 
Javascript :: material-ui.com autocomplete grouped 
Javascript :: access index of array javascript 
Javascript :: react paypal express checkout 
Javascript :: drupal 8 webform insert node twig value 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =