hiddentao / gulp-server-livereload

Gulp plugin to run a local webserver with livereload enabled via socket.io. Also comes with standalone command-line interface.
MIT License
93 stars 28 forks source link

Browser does not reload plaintext HTML document #33

Closed austinpickett closed 8 years ago

austinpickett commented 8 years ago

I'm not sure if this is how the plugin is supposed to work or not, but without any HTML elements in the document the browser does not reload that page..

Example (index.html): test no live reload

Example (index.html w/ HTML)

<html>
<head>
    <title></title>
</head>
<body>
    test
</body>
</html>

Livereload works

austinpickett commented 8 years ago

Thinking about this more in-depth, the issue is presented by the server trying to inject livereload.js on the body .. if there is no body, where is it to inject?

The only solution I could think of is checking for if not, inject body. seems more of a feature than a bug..

hiddentao commented 8 years ago

I don't think not having a valid body is a use-case this library needs to be concerned with. The current injection matching rules are:

      rules: [{
        match: /<\/body>/,
        fn: prepend
      }, {
        match: /<\/html>/,
        fn: prepend
      }, {
        match: /<\!DOCTYPE.+>/,
        fn: append
      }]

So really you just need a DOCTYPE tag to be present at the bare minimum.