an static landing page for your PDS that displays users & their bluesky posts. pds.wlo.moe
bluesky pds atproto
at main 1.4 kB view raw
1import fs from 'node:fs' 2import path from 'node:path' 3 4import vue from '@vitejs/plugin-vue' 5import { defineConfig, loadEnv } from 'vite' 6import { ZodError } from 'zod' 7import { type AppConfig, AppConfigSchema } from './src/config/schema' 8 9export default defineConfig(({ mode }) => { 10 const env = loadEnv(mode, process.cwd(), '') 11 const configFile = 12 env.APP_CONFIG_PATH ?? path.resolve(process.cwd(), `config/${mode}.json`) 13 14 let fileConfig: { 15 [key: string]: unknown 16 } = {} 17 if (fs.existsSync(configFile)) { 18 fileConfig = JSON.parse(fs.readFileSync(configFile, 'utf-8')) as { 19 [key: string]: unknown 20 } 21 } 22 23 const merged = { 24 ...fileConfig, 25 pdsService: env.VITE_PDS_SERVICE ?? fileConfig?.pdsService, 26 bskyService: env.VITE_BSKY_SERVICE ?? fileConfig?.bskyService, 27 } 28 29 let config: AppConfig | undefined 30 31 try { 32 config = AppConfigSchema.parse(merged) as AppConfig 33 } catch (e) { 34 if (e instanceof ZodError) { 35 console.error('invalid configuration.') 36 for (const issue of e.issues) 37 console.error(` ${issue.path.join('.')}: ${issue.message}`) 38 39 console.error(`\nconfig file: ${configFile}`) 40 console.error(` see schema in src/config/schema.ts\n`) 41 process.exit(1) 42 } 43 } 44 45 return { 46 plugins: [vue()], 47 define: { 48 __APP_CONFIG__: JSON.stringify(config), 49 }, 50 resolve: { 51 alias: { '@': path.resolve(__dirname, 'src') }, 52 }, 53 } 54})