hot reload does not work if the HTML does not include <body>
version 0.4.0
Describe the bug
For example, given an HTML file like this,
<style>h1 {color: blue}</style>
<h1>hello</h1>
the server will not reload when changes are made. Instead, the file has to be written like this:
<body>
<style>h1 {color: blue}</style>
<h1>hello</h1>
</body>
I think the issue is here:
https://github.com/yandeu/five-server/blob/95711266d5e5b7d95eae6107c1c4d716223cd9a8/src/middleware/injectCode.ts#L38-L51
Looks like if it does not find </head>, </html>, or </body>, then it will not inject code.
I think it should have a last resort which is to simply append the injected script tag to the end of the file (this means it will implicitly be at the end of the <body> that the browser will generate).
Pull request testing and working:
- https://github.com/yandeu/five-server/pull/154
I tested it with my project, and now all my pages work without having to wrap them with <head>, <html>, or <body>.