Hot reload for css/js files.
Start a web server that will watch your static asset bundles (js/css) for changes and notify the client via SSE.
The client will replace the <script>
or <link>
elements with the updated (and cachebusted) link, causing
the browser to load the new contents.
hot-rld -s static js/*.js css/*.css ...
-s
is the path to where your static assets are served from- followed by one or many globs to files to watch, relative to the static assets
Tip: prefix this command with ./node_modules/.bin/
if it's not already in your path.
Inject the tiny client script in your development page. This speaks to the SSE server and injects new builds of your bundle as and when they are created:
const html = `<script>${require('hot-rld/client')}</script>`
$ npm install --save-dev hot-rld
or
$ yarn add --dev hot-rld
Replacing an entire js file is likely to cause a ton of side-effects, so be mindful of
what you use it on. This was built for choo
apps which are functional in nature. However, subscriptions
and other one-time
setup side effects can still be a pain. You have been warned 😔!