| import express from 'express'; | |
| import path from 'node:path'; | |
| import { fileURLToPath } from 'node:url'; | |
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | |
| const root = path.resolve(__dirname, '..'); | |
| const dist = path.join(root, 'dist'); | |
| const app = express(); | |
| app.use('/ui/assets', express.static(path.join(dist, 'assets'))); | |
| app.get(['/ui', '/ui/', '/ui/*'], (_req, res) => { | |
| res.sendFile(path.join(dist, 'index.html')); | |
| }); | |
| app.get('/', (_req, res) => { | |
| res.redirect('/ui/'); | |
| }); | |
| const port = Number(process.env.PORT || 3000); | |
| app.listen(port, '127.0.0.1', () => { | |
| console.log(`Static preview running at http://127.0.0.1:${port}/ui/`); | |
| }); | |