【问题标题】:Lite Server hot reload doesn't work for default configLite Server 热重载不适用于默认配置
【发布时间】:2023-04-10 13:39:01
【问题描述】:

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

我没有使用 bs-config.json 文件。使用启动 lite 服务器时,我的 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 lite-server hot-reload


    【解决方案1】:

    我找到了解决办法

    “browser-sync”仅在有标签“body”时有效

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

    【讨论】:

      猜你喜欢
      • 2020-11-24
      • 1970-01-01
      • 2019-05-29
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      • 2012-12-10
      • 2023-02-15
      • 2019-10-11
      相关资源
      最近更新 更多