Arrow keys: ← previous · → next 5 of 35
@nodedk/dev
0.1.4 stable

dev#

Reload the browser after a development server restarts.

Install#

npm i -D @nodedk/dev

Usage#

Copy the script into the application's assets:

cp node_modules/@nodedk/dev/index.js app/assets/js/dev.js

Include it only in development through app/config/bundle.js, as in @nodedk/scaffold:

var { mode } = require('#env.js')
var js = ['/js/browser.js', '/js/base.js']

if (mode === 'development') {
  js.push('/js/dev.js')
}

module.exports = { css: [], js }

The script connects to the current origin over ws or wss. The server must accept that WebSocket connection. It waits 200 ms before connecting, retries after the connection closes, and reloads the page after a previously opened connection reconnects.

The package is a browser script with no exported methods or configuration parameters. A server restart before the first successful connection does not trigger a reload.

Created by Vidar Eldøy