ws-reload-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published
wsReloadPlugin 中文
Upate: Fix the bug that the new version of the chrome kernel does not refresh

a webpack auto reload plugin for chrome extension v3 developers

The run steps:
  • 1.create a websocket server and client in node,when everytime compiler is finished,send message to content client(why not service worker? it will sleep, it needs event driven)
  • 2.create a websocket client in content to receive message, then send command to service worker
  • 3.service worker listen the command to reload runtime and tab

in your webpack.config.js, add the following code

// the parameter:  { port = 7777 }
const { wsAutoReloadPlugin } = require('ws-reload-plugin')
plugins: [new wsAutoReloadPlugin()]

in your content.js(content_scripts), add the following code

// the parameter: {reconnectTime = 20, port = 7777, message = 'compiler'}
// the interval of each reconnect is 3 seconds, it will reconnect 20 times by default
const { createWsConnect } = require('ws-reload-plugin')
createWsConnect({})
// or use ES module
import { createWsConnect } from 'ws-reload-plugin'
createWsConnect({})

in your background.js(service_worker), add the following code

// the parameters and default values::  bgdListenMsg(yourMsg = 'compiler')
// yourMsg must be as same as parameters.message in createWsConnect({})
const { bgdListenMsg } = require('ws-reload-plugin')
bgdListenMsg()
// or use ES module
import { bgdListenMsg } from 'ws-reload-plugin'
bgdListenMsg()
here are all history versions npmjs

Package Sidebar

Install

npm i ws-reload-plugin

Weekly Downloads

2

Version

1.1.1

License

ISC

Unpacked Size

9.42 kB

Total Files

6

Last publish

Collaborators

  • xzz2022