1.3.0 • Published 1 year ago

tiny-livereload v1.3.0

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Tiny Livereload

A tiny and basic livereload solution.

It's divided into a frontend and a backend, basically the frontend queries the backend, the backend returns a string for that query, and whenever this string changes the page is reloaded.

Install

npm install --save tiny-livereload

Usage

A fetch frontend is provided, which polls /__livereload_page__ and /__livereload_style__ in a loop.

It reloads the page automatically when the page endpoint returns an update, and it reloads styles without reloading the page when the style endpoint returns an update.

import livereload from 'tiny-livereload/fetch';

// Check for updates

livereload ();

An express middleware for the backend is provided, which serves the /__livereload_page__ and /__livereload_style__ endpoints, potentially watching some paths for changes too.

import express from 'express';
import livereload from 'tiny-livereload/express';

const app = express ();

// Only handle restarts of the server

app.use ( livereload () );

// Also watch some paths for changes

const watchPathsForPage = ['./dist/client'];
const watchPathsForStyle = ['./public/style'];

app.use ( livereload ( watchPathsForPage, watchPathsForStyle ) );

License

MIT © Fabio Spampinato

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago