1.1.2 • Published 1 year ago

ws-reload-plugin v1.1.2

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

20240613update: Fixed the bug that the new version of chrome refresh failed!

wsReloadPlugin 中文

A webpack plugin for chrome extension v3 developers to compile and automatically refresh

Implementation principle:
  • 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 and needs event driven)
  • 2.create a websocket client in content to receive message, then send command to service worker(background)
  • 3.service worker listen the command to reload runtime and current tab
  1. Installation Commands:
npm install ws-reload-plugin --save-dev
  1. Add the following code to the webpack.config.js file
// the parameter:  { port = 7777 }
const { wsAutoReloadPlugin } = require('ws-reload-plugin')
plugins: [new wsAutoReloadPlugin()]
  1. Add the following code to the content.js(content_scripts) file
/* When the ws service is disconnected, it will automatically reconnect,
with an interval of 3 seconds each time, and the default reconnection is 20 times */
const { createWsConnect } = require('ws-reload-plugin')
createWsConnect()
// or use ES module
import { createWsConnect } from 'ws-reload-plugin'
createWsConnect()
  1. Add the following code to your service_worker(background) file
// 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()
my complete vue3-based cli for extension develop
here are all history versions npmjs
1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago