summaryrefslogtreecommitdiffhomepage
path: root/vite.config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'vite.config.ts')
-rw-r--r--vite.config.ts36
1 files changed, 35 insertions, 1 deletions
diff --git a/vite.config.ts b/vite.config.ts
index d32eba1..80a4102 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,7 +1,41 @@
import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'
+import tailwindcss from '@tailwindcss/vite'
+import fs from 'fs'
+
+const port = parseInt(process.env.VITE_PORT || '5188')
+const apiPort = process.env.VITE_API_PORT || '3100'
+const host = process.env.VITE_HOST || 'arch-razer.chimera-dinosaur.ts.net'
+
+const certPath = 'tmp/tls/cert.pem'
+const keyPath = 'tmp/tls/key.pem'
+const hasCerts = fs.existsSync(certPath) && fs.existsSync(keyPath)
// https://vite.dev/config/
export default defineConfig({
- plugins: [svelte()],
+ plugins: [tailwindcss(), svelte()],
+ server: {
+ port,
+ host: '0.0.0.0',
+ ...(hasCerts
+ ? {
+ https: {
+ cert: fs.readFileSync(certPath),
+ key: fs.readFileSync(keyPath),
+ },
+ }
+ : {}),
+ proxy: {
+ '/api': {
+ target: `https://${host}:${apiPort}`,
+ changeOrigin: true,
+ secure: false,
+ },
+ '/cable': {
+ target: `wss://${host}:${apiPort}`,
+ ws: true,
+ secure: false,
+ },
+ },
+ },
})