Skip to content

Instantly share code, notes, and snippets.

@jukbot
Last active July 6, 2024 02:32
Show Gist options
  • Save jukbot/152d7bb7a015885b01276efda5b55261 to your computer and use it in GitHub Desktop.
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
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.
@jukbot
Copy link
Author

jukbot commented Jul 5, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment