Last active
October 11, 2024 15:19
-
-
Save jukbot/152d7bb7a015885b01276efda5b55261 to your computer and use it in GitHub Desktop.
Example of serving static files (eg. build from vite) using Elysia and bun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Elysia } from "elysia"; | |
import { staticPlugin } from '@elysiajs/static'; | |
const app = new Elysia() | |
app.use(staticPlugin({ | |
prefix: '', | |
assets : "./dist", | |
})) | |
app.get('/', async () => { | |
return Bun.file('./dist/index.html') | |
}) | |
app.listen(3000, () => { | |
console.log(`🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`); | |
}) | |
// Note: if you set (base: './') in vite.config.js you must remove prefix: '' config in staticPlugin option in order to work. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using this dockerfile to run
https://gist.github.com/jukbot/289784bdea2909463249a9ef82371f32