import { resolve } from 'node:path' import { fileURLToPath } from 'node:url' import { defineConfig } from 'vite' const __dirname = fileURLToPath(new URL('.', import.meta.url)) /** * The engine is plain TypeScript with no runtime dependencies: Vite only serves * and bundles it. Two entries: the real campaign scene (`acts.html`) and the * combat math arena (`arena.html`). `samples/` is served in dev so all of them can * be smoke-tested over HTTP (`?sample=samples/spawn.mpq`, * `?data=samples/fixtures`). */ export default defineConfig({ server: { host: '127.0.0.1', port: 5173, strictPort: true, }, plugins: [ { name: 'root-redirect', configureServer(server) { server.middlewares.use((req, res, next) => { if (req.url === '/' || req.url === '/index.html') { res.writeHead(302, { Location: '/acts.html' }) res.end() return } next() }) }, generateBundle() { this.emitFile({ type: 'asset', fileName: 'index.html', source: 'd2web跳转至暗黑破坏神 2 游戏主界面\n', }) }, }, ], build: { target: 'es2022', sourcemap: true, rollupOptions: { input: { acts: new URL('./acts.html', import.meta.url).pathname, arena: new URL('./arena.html', import.meta.url).pathname, loot: resolve(__dirname, 'loot.html'), boss: resolve(__dirname, 'boss.html'), }, }, }, })