hot-reload-extension-vite
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -9,11 +9,15 @@ "use strict"; | ||
if (isDev) { | ||
const socket = new WebSocket( | ||
`ws://localhost:${HOT_RELOAD_EXTENSION_VITE_PORT}` | ||
); | ||
socket.addEventListener("message", (event) => { | ||
if (event.data === "file-change" /* FILE_CHANGE */) { | ||
chrome.runtime.reload(); | ||
chrome.tabs.reload(); | ||
} | ||
}); | ||
try { | ||
const socket = new WebSocket( | ||
`ws://localhost:${HOT_RELOAD_EXTENSION_VITE_PORT}` | ||
); | ||
socket.addEventListener("message", (event) => { | ||
if (event.data === "file-change" /* FILE_CHANGE */) { | ||
chrome.runtime.reload(); | ||
chrome.tabs.reload(); | ||
} | ||
}); | ||
} catch (e) { | ||
console.info("Please run `npm run dev` to start socket.", e); | ||
} | ||
} |
{ | ||
"name": "hot-reload-extension-vite", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Simple vite plugin to reload the chrome extension.", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
@@ -5,5 +5,5 @@ # Hot Reload Chrome Extension - Vite Plugin | ||
Inspired by [stackoverflow answer](https://stackoverflow.com/a/65485938/7135342) and other similar repo. | ||
Inspired by [stackoverflow answer](https://stackoverflow.com/a/65485938/7135342) and other similar repos. | ||
![demo](https://raw.githubusercontent.com/isaurssaurav/hot-reload-extension-vite/main/demo/demo.png) | ||
![image](https://raw.githubusercontent.com/isaurssaurav/hot-reload-extension-vite/main/image.png) | ||
@@ -36,3 +36,3 @@ ## Usage | ||
```bash | ||
$ NODE_ENV=development vite build --watch | ||
$ NODE_ENV=development vite build --watch // Override NODE_ENV | ||
``` | ||
@@ -42,6 +42,2 @@ | ||
## Running example | ||
In progress | ||
## Options | ||
@@ -52,6 +48,12 @@ | ||
| log | boolean (optional) | Logs error and info. | | ||
| backgroundPath | string(required) | Path to background service worker file. | | ||
| backgroundPath | string (required) | Path to background service worker file. | | ||
## Env variables | ||
| Variable | default | Description | | ||
| ------------------------------ | ------- | --------------- | | ||
| HOT_RELOAD_EXTENSION_VITE_PORT | 8080 | Web socket port | | ||
## License | ||
MIT |
Sorry, the diff of this file is not supported yet
40211
1165
56