You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Automatically update your CSS in real-time, without having to add a single line of code to your project's codebase.
3
+
Automatically reload your HTML, CSS, and image resources within the browsre in real-time, without having to add a single line of code to your project's codebase.
4
4
5
5
- 🪶 Lightweight
6
6
- 🌻 Works with vanilla JS
@@ -12,7 +12,7 @@ Automatically update your CSS in real-time, without having to add a single line
12
12
13
13
Frameworks like [React](https://github.com/facebook/react) have spoiled us with features like HMR (hot module reload), reducing developer friction when making small, incremental changes. Wouldn't it be nice to have a lightweight solution for vanilla JS projects, without having to use a framework?
14
14
15
-
And so, Web Hot Reloader was born. It consists of two parts: a Node.js process that lists to a directory for CSS file changes, and a script to inject websocket code into your web page.
15
+
And so, Web Hot Reloader was born. It consists of two parts: a Node.js process that watches to a directory for file changes, and a script to inject WebSocket code into your web page.
16
16
17
17
## Setup
18
18
@@ -23,21 +23,23 @@ Prerequisites:
23
23
-[Node.js](https://nodejs.org/en/download)
24
24
- Clone the repo
25
25
26
-
### Running the program
26
+
Ensure `node_modules` are installed with `pnpm i` (`npm i` will also work, but will generate a `package-lock.json` file)
27
27
28
-
In my project, there is a `/css` folder containing all the CSS files. (See: [Current limitations](#current-limitations))
28
+
### Running the program
29
29
30
-
To initialize the hot reloader for this directory, we can type the following:
30
+
To initialize the hot reloader for this project, we can type the following:
31
31
32
32
```cmd
33
-
node app C:\xampp\app\brethudson\css
33
+
node app C:\xampp\app\brethudson
34
34
```
35
35
36
36
Tip: You can override `PORT` (default `3008`) and `NODE_ENV` (default `production`) in your environment variables.
37
37
38
38
### Getting your browser to listen
39
39
40
-
Now, while you _could_ copy/paste [public/reloader.js](public/reloader.js) into your project and include it in every page that you want to use it on, that doesn't scale well, and also means that you would need to ensure it gets removed for the production/live site.
40
+
(Coming soon: built-in proxy server)
41
+
42
+
Now, while you _could_ copy/paste [public/reloader.js](public/reloader.js) into your project and include it in every page that you want to use it on, that doesn't scale well, and also means that you would need to ensure it gets removed in the production/live site.
41
43
42
44
What I suggest is grabbing a browser extension such as [Tampermonkey](https://www.tampermonkey.net/), which will allow us to run scripts on certain pages!
43
45
@@ -47,16 +49,19 @@ Within this file, every `@match` line will correspond to a URL path to match. Fo
47
49
48
50
## Current limitations
49
51
50
-
- Only CSS files are supported
51
-
- No recursive folder watching
52
+
- Only HTML, CSS, and image files are supported
53
+
-~~No recursive folder watching~~
52
54
- JS support is not currently on the roadmap
55
+
- No automatic script injection
53
56
54
57
## Future plans
55
58
56
59
There really aren't any specific ones! Some things I would like to add:
57
60
58
-
- Recursive listening (`C:/project/css` would be able to listen to `C:/project/css/sub-folder` as well - meaning it would be possible to just use `C:/project` as the directory)
59
-
- <img> support
60
-
- JS support
61
-
- Project configuration files (`reloader.json` or `reloader.config.js`)
62
-
- Publish to `npm`
61
+
-[x]~~Recursive listening (`C:/project/css` would be able to listen to `C:/project/css/sub-folder` as well - meaning it would be possible to just use `C:/project` as the directory)~~
62
+
-[x]~~HTML reloading support~~
63
+
-[x]~~`<img>`/favicon reloading support~~
64
+
-[ ] Proxy server with hot reloader injection magic
65
+
-[ ] Project configuration files (`reloader.json` or `reloader.config.js`)
0 commit comments