You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
2 years ago
|
import { defineConfig } from 'vite'
|
||
2 years ago
|
import { resolve } from 'path'
|
||
2 years ago
|
|
||
2 years ago
|
import preact from '@preact/preset-vite'
|
||
|
|
||
|
const entryPoints = ['index', 'login', 'register', 'user', 'game', 'crea-partita']
|
||
2 years ago
|
|
||
|
const redirect = redirectMap => ({
|
||
|
name: 'redirect',
|
||
|
configureServer(server) {
|
||
|
server.middlewares.use((req, res, next) => {
|
||
|
if (!!redirectMap[req.url]) {
|
||
|
res.statusCode = 302
|
||
|
res.setHeader('Location', redirectMap[req.url])
|
||
|
res.setHeader('Content-Length', '0')
|
||
|
res.end()
|
||
|
} else {
|
||
|
next()
|
||
|
}
|
||
|
})
|
||
|
},
|
||
|
})
|
||
|
|
||
2 years ago
|
const redirectMap = Object.fromEntries(entryPoints.map(page => ['/' + page, '/' + page + '.html']))
|
||
2 years ago
|
|
||
|
export default defineConfig({
|
||
|
build: {
|
||
|
rollupOptions: {
|
||
|
input: Object.fromEntries(
|
||
2 years ago
|
entryPoints.map(page => [page, resolve(__dirname, page + '.html')])
|
||
2 years ago
|
),
|
||
|
},
|
||
|
},
|
||
|
server: {
|
||
|
proxy: {
|
||
|
'/api': 'http://127.0.0.1:4000',
|
||
|
},
|
||
|
},
|
||
2 years ago
|
plugins: [preact(), redirect(redirectMap)],
|
||
2 years ago
|
})
|