creates video voice memos from audio clips; with bluesky integration. trill.ptr.pet
at main 2.8 kB view raw
1import { defineConfig } from "vite"; 2import solidPlugin from "vite-plugin-solid"; 3import devtools from "solid-devtools/vite"; 4import tsconfigPaths from "vite-tsconfig-paths"; 5import oauthMetadata from "./src/lib/oauthMetadata.json"; 6 7export const makeOauthMetadata = ( 8 client_id: string, 9 client_uri: string, 10 redirect_uri: string, 11 scope: string, 12) => ({ 13 ...oauthMetadata, 14 client_id, 15 client_uri, 16 logo_uri: `${client_uri}/favicon.png`, 17 redirect_uris: [redirect_uri], 18 scope, 19}); 20 21export default defineConfig({ 22 plugins: [ 23 { 24 name: "oauth-metadata", 25 config(_conf, { command }) { 26 if (command !== "build") { 27 process.env.VITE_CLIENT_URI = "http://localhost:3000"; 28 const redirectUri = "http://127.0.0.1:3000"; 29 process.env.VITE_OAUTH_REDIRECT_URL = redirectUri; 30 const scope = oauthMetadata.scope; 31 process.env.VITE_OAUTH_SCOPE = scope; 32 process.env.VITE_OAUTH_CLIENT_ID = 33 `http://localhost` + 34 `?redirect_uri=${encodeURIComponent(redirectUri)}` + 35 `&scope=${encodeURIComponent(scope)}`; 36 } 37 }, 38 configureServer(server) { 39 server.middlewares.use((req, res, next) => { 40 if (req.headers.host?.startsWith("127.0.0.1")) { 41 const newUrl = `http://localhost:${req.headers.host.split(":")[1] || "3000"}${req.url}`; 42 res.writeHead(301, { Location: newUrl }); 43 res.end(); 44 return; 45 } 46 next(); 47 }); 48 server.middlewares.use((req, res, next) => { 49 if (req.url === "/oauth-client-metadata.json") { 50 res.setHeader("Content-Type", "application/json"); 51 res.end( 52 JSON.stringify( 53 makeOauthMetadata( 54 process.env.VITE_OAUTH_CLIENT_ID!, 55 process.env.VITE_CLIENT_URI!, 56 process.env.VITE_OAUTH_REDIRECT_URL!, 57 process.env.VITE_OAUTH_SCOPE!, 58 ), 59 null, 60 2, 61 ), 62 ); 63 return; 64 } 65 next(); 66 }); 67 }, 68 generateBundle() { 69 this.emitFile({ 70 type: "asset", 71 fileName: "oauth-client-metadata.json", 72 source: JSON.stringify( 73 makeOauthMetadata( 74 process.env.VITE_OAUTH_CLIENT_ID!, 75 process.env.VITE_CLIENT_URI!, 76 process.env.VITE_OAUTH_REDIRECT_URL!, 77 process.env.VITE_OAUTH_SCOPE!, 78 ), 79 null, 80 2, 81 ), 82 }); 83 }, 84 }, 85 devtools(), 86 solidPlugin(), 87 tsconfigPaths({ root: "./" }), 88 ], 89 server: { 90 host: "0.0.0.0", 91 port: 3000, 92 }, 93 build: { 94 target: "esnext", 95 }, 96});