Closed ckken closed 2 months ago
Hi @ckken hmm....
I think it was already implemented in Hono.
app.use(serveStatic({ root: staticPath }) }) // dist
app.get('*', (c) => c.html(html)) // html in dist
we use hono replace express in webpack cli,Absolute root path must be use in express.static
hmm... I think it's unnecessary. You can use a relative path.
app.use(serveStatic({ root: "./dist" }) }) // dist
app.get('*', (c) => c.html(html)) // html in dist
If we don't think the problem of performance, you can use .mount()
The cli does not exist in the project, but is installed through npm, while hono is integrated into the cli, so there are similar demos
I may be mistaken. Do you want to migrate express to hono? Do you want to migrate hono to express? Or another? @ckken
hmm... I'm not quite sure what the intent is. sorry
please explain the details?
fixed it!
import {serveStatic} from 'hono/serve-static'
app.use(
'*',
serveStatic({
root: '/',
pathResolve(filePath: string) {
return path.resolve(store.outDir, filePath)
},
getContent(filePath, c) {
return fsp.readFile(filePath)
},
}),
)
Good, I'm relieved.
What is the feature you are proposing?
app.use(express.static(staticRoot))//dist app.get('*', (req, res) => res.send(html))//html in dist