chrome-dev-sync

1.0.15 • Public • Published

Why this package ?

the browser-sync cannot reload development server when the code has some bug and server can not start, so the reload module cannot be load and communication between build-tool and web-server broken. every thing is failure.

This module start server file and watch development files by browser-sync. when server initalized, this module will force chrome reload-page.

usage:

var chromeDev = require("chrome-dev");
  chromeDev( options:IOptions)
  
 
interface IOptions {
    url:string; // open url after retrive "online" signal
    server:string; // server file will be execution,
    setup:()=>Promise<any> // run this job before start
}

NOTE: when server application bootstrap, it must send "online" message to parent process

example:

server.js

var express=require("express");
var app=express();
app.listen(3000,function(){
   if (process.send) process.send("online");
})

server-dev.js

var chromeDev = require("chrome-dev");
var app = chromeDev({
   url: "http://localhost:3000",
   server: "./server.js"
   setup: (self) => {
      self.ignore([/node_modules|\.git|\.cache|static|\.marko\.js/])
        .watch((event,fileName)=>{
           if (fileName.match(/ignoreme/)) return Promise.reject(); // dont restart server  
           return Promise.resolve(); // do restart server
        });
      return Promise.resolve();
   }
})
run application in development mode
> node server-dev.js
run application in production mode
> node server.js

Readme

Keywords

none

Package Sidebar

Install

npm i chrome-dev-sync

Weekly Downloads

1

Version

1.0.15

License

ISC

Unpacked Size

13.5 kB

Total Files

7

Last publish

Collaborators

  • tungbt