38 lines
952 B
TypeScript
38 lines
952 B
TypeScript
import path from "path";
|
|
import fs from "fs";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
// SSL certificate paths
|
|
const sslCertPath = path.join(process.cwd(), "ssl/termix.crt");
|
|
const sslKeyPath = path.join(process.cwd(), "ssl/termix.key");
|
|
|
|
// Check if SSL certificates exist and HTTPS is requested
|
|
const hasSSL = fs.existsSync(sslCertPath) && fs.existsSync(sslKeyPath);
|
|
const useHTTPS = process.env.VITE_HTTPS === "true" && hasSSL;
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [react(), tailwindcss()],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
base: "./",
|
|
build: {
|
|
sourcemap: false,
|
|
},
|
|
server: {
|
|
https: useHTTPS
|
|
? {
|
|
cert: fs.readFileSync(sslCertPath),
|
|
key: fs.readFileSync(sslKeyPath),
|
|
}
|
|
: false,
|
|
port: 5173,
|
|
host: "localhost",
|
|
},
|
|
});
|