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