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

问题描述 投票:1回答:1

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

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

启动lite服务器时,我的index.html会在新选项卡中正确打开。

npm run dev

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

> [email protected] 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 lite-server hot-reload
1个回答
1
投票

我找到了解决方法

“浏览器同步”仅在标记为“ body”的情况下有效]

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

© www.soinside.com 2019 - 2024. All rights reserved.