Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert #7665 #7716

Merged
merged 1 commit into from Apr 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 2 additions & 12 deletions packages/vite/src/node/preview.ts
@@ -1,5 +1,4 @@
import path from 'path'
import fs from 'fs'
import sirv from 'sirv'
import connect from 'connect'
import compression from './server/middlewares/compression'
Expand Down Expand Up @@ -91,20 +90,11 @@ export async function preview(
config.base,
sirv(distDir, {
etag: true,
dev: true
dev: true,
single: true
})
)

app.use(config.base, (_, res, next) => {
const file = path.join(distDir, './404.html')
if (fs.existsSync(file)) {
res.statusCode = 404
res.end(fs.readFileSync(file))
} else {
next()
}
})

const options = config.preview
const hostname = resolveHostname(options.host)
const port = options.port ?? 4173
Expand Down