import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import plugin from '@vitejs/plugin-react' import fs from 'fs' import path from 'path' const certificateName = "reactapp1.client" const baseFolder = process.env.APPDATA !== undefined && process.env.APPDATA !== '' ? `${process.env.APPDATA}/ASP.NET/https` : `${process.env.HOME}/.aspnet/https` const certFilePath = path.join(baseFolder, `${certificateName}.pem`) const keyFilePath = path.join(baseFolder, `${certificateName}.key`) // création certificat uniquement si absent if (!fs.existsSync(baseFolder)) { fs.mkdirSync(baseFolder, { recursive: true }) } export default defineConfig({ plugins: [plugin()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, server: { https: { key: fs.readFileSync(keyFilePath), cert: fs.readFileSync(certFilePath), }, port: 5173 } })