oidc-vue-test/vite.config.ts

45 lines
1 KiB
TypeScript
Raw Permalink Normal View History

//
// Webcrypto is required for docoding the tokens, and thus https is compulsary.
//
// Read an environment file (.env) at the project's root,
// with 2 variables VITE_SSL_KEY and VITE_SSL_CERT defining the location
// of the ssl key and cert
//
2025-01-25 02:23:43 +01:00
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, UserConfig, loadEnv } from 'vite'
2025-01-25 02:23:43 +01:00
import fs from 'fs';
import path from 'path';
import vue from '@vitejs/plugin-vue'
2025-01-26 03:52:08 +01:00
//import vueDevTools from 'vite-plugin-vue-devtools'
2025-01-25 02:23:43 +01:00
// Read the env file
const env = loadEnv("dev", ".")
2025-01-28 19:50:17 +01:00
let baseSettings: UserConfig = {
2025-01-25 02:23:43 +01:00
plugins: [
vue(),
2025-01-26 03:52:08 +01:00
//vueDevTools(),
2025-01-25 02:23:43 +01:00
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
2025-01-28 19:50:17 +01:00
},
}
if (env.VITE_SSL_CERT && env.VITE_SSL_KEY) {
2025-01-28 19:50:17 +01:00
baseSettings['server'] = {
2025-02-01 01:19:13 +01:00
hmr: false,
2025-01-28 19:50:17 +01:00
https: {
key: fs.readFileSync(path.resolve(env.VITE_SSL_KEY)),
cert: fs.readFileSync(path.resolve(env.VITE_SSL_CERT))
2025-01-28 19:50:17 +01:00
}
2025-01-25 02:23:43 +01:00
}
2025-01-28 19:50:17 +01:00
}
// https://vite.dev/config/
export default defineConfig(baseSettings)