3.2.14 • Published 29 days ago

dk-reload-server v3.2.14

Weekly downloads
-
License
MIT
Repository
github
Last release
29 days ago

Reload browser on files change

npm license

Installation

Add dk-reload-server to package.json and install.

Features

  • reloads browser by WebSocket connection when watched files have been modified
  • aggregates changed files by aggregationTimeout
  • logs changed files if needed
  • works by http or https

Compared to browser-refresh this app has much less code and dependencies, does not modify process.env, includes basic SSL certificates, does not replace main server start command (to browser-refresh server.js instead of node server.js), does not need process.send('online') to start working, does not depend on Node.js server restart (you mostly just rebuild client files and don't need to restart server).

When to use

Most of bundlers can handle page reloads by their own WebSocket server implementations, but you have to use their dev-servers or middlewares. When you have custom Backend-For-Frontend server that is built by separate process and bundler config or even by other bundler, these solutions would not work properly.

Usage

  1. Create file that will start reload server and file watcher (ex. src/watchServer.ts)
import path from 'path';

import { run } from 'dk-reload-server';

run({
  port: 401,
  https: true,
  watchPaths: [path.resolve(__dirname, '../build')],
  changedFilesLogs: true,
  aggregationTimeout: 50,
});
  1. Add to html template (presumably via template modification on server start)
<script src="https://localhost:401"></script>
  1. Add recipe like this to package.json scripts section
{
  "reload-browser": "yarn -s babel-node --extensions .ts ./src/watchServer.ts"
}

Run and stop when you need (presumably run after dev build completed and stop on SIGINT).

Params

  • port (number) - on which port server will start
  • watchPaths (array of strings) - absolute paths of watched folders or files
  • https (boolean) (optional) - use https protocol or not
  • ignored (optional) - passed directly to chokidar ignored param, so files by this pattern will not trigger page reload
  • changedFilesLogs (boolean) (optional) - show modified files that trigger page reload in console
  • aggregationTimeout (number) (optional) - aggregate changed file for this period in ms
3.2.9

29 days ago

3.2.13

29 days ago

3.2.12

29 days ago

3.2.14

29 days ago

3.2.11

29 days ago

3.2.10

29 days ago

3.2.8

1 month ago

3.2.7

1 month ago

3.2.6

1 month ago

3.2.6-alpha.0

1 month ago

3.2.2

1 month ago

3.2.3

1 month ago

3.2.1

1 month ago

3.2.0

1 month ago

3.1.43

3 months ago

3.1.42

3 months ago

3.1.41

3 months ago

3.1.40

3 months ago

3.1.39

3 months ago

3.1.38

4 months ago

3.1.16

10 months ago

3.1.15

10 months ago

3.1.18

10 months ago

3.1.17

10 months ago

3.1.23

9 months ago

3.1.22

10 months ago

3.1.25

9 months ago

3.1.24

9 months ago

3.1.27

7 months ago

3.1.26

9 months ago

3.1.29

7 months ago

3.1.28

7 months ago

3.1.21

10 months ago

3.1.20

10 months ago

3.1.19

10 months ago

3.1.34

6 months ago

3.1.33

6 months ago

3.1.36

5 months ago

3.1.35

6 months ago

3.1.37

5 months ago

3.1.30

7 months ago

3.1.32

6 months ago

3.1.31

6 months ago

3.1.12

11 months ago

3.1.11

11 months ago

3.1.14

11 months ago

3.1.13

11 months ago

3.1.9

11 months ago

3.1.8

11 months ago

3.0.18

11 months ago

3.0.19

11 months ago

3.0.9

11 months ago

3.0.4

11 months ago

3.1.2

11 months ago

3.0.13

11 months ago

3.1.1

11 months ago

3.0.10

11 months ago

3.1.0

11 months ago

3.0.11

11 months ago

3.1.7

11 months ago

3.0.16

11 months ago

3.0.8

11 months ago

3.1.6

11 months ago

3.0.17

11 months ago

3.0.7

11 months ago

3.1.5

11 months ago

3.0.14

11 months ago

3.0.6

11 months ago

3.1.4

11 months ago

3.0.15

11 months ago

2.0.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago