Skip to content

Commit

Permalink
fix: Support refresh and livereload in serve when using routerMode hi…
Browse files Browse the repository at this point in the history
…story (#166)
  • Loading branch information
Peksa authored Feb 14, 2022
1 parent 238326e commit 625c9f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const serveStatic = require('serve-static')
const connect = require('connect')
const livereload = require('connect-livereload')
const history = require('connect-history-api-fallback')
const lrserver = require('livereload')
const open = require('open')
const chalk = require('chalk')
Expand All @@ -27,7 +28,8 @@ module.exports = function (
})
.then(_ => {
path = resolve(path || '.')
const indexFile = resolve(path, indexName || 'index.html')
const indexFileName = indexName || 'index.html'
const indexFile = resolve(path, indexFileName)

if (!exists(indexFile)) {
const msg =
Expand All @@ -46,6 +48,7 @@ module.exports = function (
port: livereloadPort
})
)
server.use(history({index: '/' + indexFileName}))
server.use(serveStatic(path, {index: indexName}))
server.listen(port)
lrserver
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"dependencies": {
"chalk": "^2.4.2",
"connect": "^3.6.0",
"connect-history-api-fallback": "^1.6.0",
"connect-livereload": "^0.6.0",
"cp-file": "^7.0.0",
"docsify": "^4.12.2",
Expand Down

0 comments on commit 625c9f2

Please sign in to comment.