saudade/vite.config.js

40 lines
973 B
JavaScript
Raw Normal View History

2023-06-09 12:52:42 -07:00
import {defineConfig} from 'vite'
2023-06-09 13:55:00 -07:00
import {resolve} from 'node:path'
import {homedir} from 'node:os'
import fs from 'node:fs'
2023-06-09 12:52:42 -07:00
2023-06-09 13:55:00 -07:00
// noinspection JSUnusedGlobalSymbols
export default defineConfig({
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
wordfire: resolve(__dirname, 'wordfire/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),
},
}
}