Lite Server 热重载不适用于默认配置

Lite Server hot reload doesn't work for default config

Lite Server 在更改我的 index.html 文件后不会重新加载页面。

我没有使用 bs-config.json 文件。使用 :

启动精简版服务器时,我的 index.html 在新选项卡中正确打开

npm run dev

此控制台信息可能有帮助:

> lite@1.0.0 dev C:\test\lite
> lite-server

Did not detect a `bs-config.json` or `bs-config.js` override file. Using lite-server defaults...
** browser-sync config **
{ injectChanges: false,
  files: [ './**/*.{html,htm,css,js}' ],
  watchOptions: { ignored: 'node_modules' },
  server: { baseDir: './', middleware: [ [Function], [Function] ] } }
[Browsersync] Access URLs:
 -------------------------------------
       Local: http://localhost:3000
    External: http://192.168.1.39:3000
 -------------------------------------
          UI: http://localhost:3001
 UI External: http://localhost:3001
 -------------------------------------
[Browsersync] Serving files from: ./
[Browsersync] Watching files...
19.07.26 21:02:27 304 GET /index.html
[Browsersync] Reloading Browsers...

更改和保存我的 index.html 时,

[BrowserSync] 'Reloading Browsers' 

出现在我的控制台中,但我的页面不会重新加载。 我需要按 F5 然后

19.07.26 21:09:32 200 GET /index.html

出现在我的控制台中。

Package.json :

{
  "name": "lite",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
      "dev": "lite-server"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "lite-server": "^2.5.3"
  }
}

如何让 Lite Server 热重载我的页面?

我找到了解决方案

"browser-sync" 仅在有标签 "body"

时有效

只需在 html 页面中添加 body 标签