38 lines
986 B
TypeScript
38 lines
986 B
TypeScript
import { existsSync, readFileSync } from 'node:fs'
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
import { defineConfig } from 'vite'
|
|
import type { ServerOptions } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
|
|
|
const certificateKeyPath = fileURLToPath(
|
|
new URL('../../.cert/localhost-key.pem', import.meta.url),
|
|
)
|
|
const certificatePath = fileURLToPath(
|
|
new URL('../../.cert/localhost.pem', import.meta.url),
|
|
)
|
|
const serverOptions: ServerOptions = {}
|
|
|
|
if (existsSync(certificateKeyPath) && existsSync(certificatePath)) {
|
|
serverOptions.https = {
|
|
key: readFileSync(certificateKeyPath),
|
|
cert: readFileSync(certificatePath),
|
|
}
|
|
}
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
server: serverOptions,
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
vueDevTools(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
})
|