1.0.0 • Published 20 days ago

hexo-browser-reloader-websocket v1.0.0

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

npm version CI | Coverage Report

hexo-browser-reloader-websocket

Automatically reloads the browser when files are modified while the hexo-server is running. Inspired by hexo-browsersync.

Usage

hexo-browser-reloader-websocket is transparent. Once installed, just run hexo-server.

!WARNING Please DO NOT USE in production (It means do not run hexo-server in production).

  • Please use this plugin only for development (local environment).
  • Hexo is a static site generator. It is not intended to run hexo-server in production.
  • This plugin does not encrypt between the WebSocket server and client.

Install

npm i hexo-browser-reloader-websocket

Configuration

Example (Defalut):

# _config.yml
browser_reloader_websocket:
  enable: true
  server:
    port: 4001
  notification:
    message: "reloadBrowser"
    wait:
      min: 150 # ms
      autoCalc:
        enable: true
        coefficient: 1.0
keytypedescriptiondefault
enablebooleanManage enable or disable this plugin.true
portnumberWebSocket server's port.4001
messagestringWebSocket message event data.reloadBrowser
wait.minnumberMinimum waiting time for reload browser after detecting file changes. Pleasse see About wait time.150
wait.autoCalc.enablebooleanCalculate the waiting time for the reload browser after detecting file changes based on the number of routes. Pleasse see About wait time.true
wait.autoCalc.coefficientnumberCoefficient for calculate wait time if autoCalc is enabled.1.0

About wait time

Reloading the browser by this plugin may be faster than the hexo-server's router updating if there are few routes or a lot of routes. The router updating depends on the number of post, pages, assets, tags, categories...etc. Also it depends on theme, plugins and machine power etc.

The wait option for resolve this, wait a little bit after file change detection before starting the browser reload.

About wait.autoCalc calculation formula

If the wait.autoCalc.enabled option is true, the plugin calculates the waiting time based on the number of routes. Below is a calculation formula.

// calculation formula
(<number of routes> / 10) * <autoCalc.coefficient> = wait(ms)

// example
(1200 / 10) * 0.9 = 108ms

Logger

Please see logger docs if you need.

1.0.0

20 days ago

1.0.0-rc2

26 days ago

1.0.0-rc3

25 days ago

1.0.0-rc1

29 days ago