40 lines
1 KiB
JavaScript
40 lines
1 KiB
JavaScript
import {defineConfig} from 'vite'
|
|
import {resolve} from 'node:path'
|
|
import {homedir} from 'node:os'
|
|
import fs from 'node:fs'
|
|
|
|
// noinspection JSUnusedGlobalSymbols
|
|
export default defineConfig({
|
|
build: {
|
|
rollupOptions: {
|
|
input: {
|
|
main: resolve(__dirname, 'index.html'),
|
|
wordfire: resolve(__dirname, 'wordfire/index.html'),
|
|
petz5world: resolve(__dirname, 'petz5world/index.html'),
|
|
},
|
|
},
|
|
},
|
|
server: detectServerConfig('saudade.test'),
|
|
})
|
|
|
|
function detectServerConfig(host) {
|
|
let keyPath = resolve(homedir(), `.config/valet/Certificates/${host}.key`)
|
|
let certificatePath = resolve(homedir(), `.config/valet/Certificates/${host}.crt`)
|
|
|
|
if (!fs.existsSync(keyPath)) {
|
|
return {}
|
|
}
|
|
|
|
if (!fs.existsSync(certificatePath)) {
|
|
return {}
|
|
}
|
|
|
|
return {
|
|
hmr: {host},
|
|
host,
|
|
https: {
|
|
key: fs.readFileSync(keyPath),
|
|
cert: fs.readFileSync(certificatePath),
|
|
},
|
|
}
|
|
}
|