Compare commits

...

2 Commits

Author SHA1 Message Date
Rami Bitar
39246219d2 update remove vite config aiPlugin 2026-05-03 20:42:56 -04:00
Rami Bitar
8ca6e20ae2 remove shadcn import 2026-05-03 20:38:37 -04:00
3 changed files with 2 additions and 58 deletions

View File

@@ -1,6 +0,0 @@
# Shopify (defaults to mock.shop if unset)
VITE_SHOPIFY_DOMAIN=mock.shop
VITE_SHOPIFY_STOREFRONT_ACCESS_TOKEN=
# Anthropic — used by /api/chat. Required for the AI panel.
ANTHROPIC_API_KEY=

View File

@@ -44,7 +44,6 @@
"react": "^19.1.1", "react": "^19.1.1",
"react-dom": "^19.1.1", "react-dom": "^19.1.1",
"react-router": "^7.0.0", "react-router": "^7.0.0",
"shadcn": "^4.6.0",
"tailwind-merge": "^3.5.0", "tailwind-merge": "^3.5.0",
"tailwindcss": "^4.1.11", "tailwindcss": "^4.1.11",
"tw-animate-css": "^1.4.0", "tw-animate-css": "^1.4.0",

View File

@@ -1,56 +1,7 @@
import { defineConfig, loadEnv, type Plugin } from "vite"; import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react"; import react from "@vitejs/plugin-react";
import path from "node:path"; import path from "node:path";
function apiChatPlugin(): Plugin {
return {
name: "api-chat-middleware",
configureServer(server) {
server.middlewares.use("/api/chat", async (req, res, next) => {
if (req.method !== "POST") return next();
try {
const mod = await server.ssrLoadModule("/api/chat.ts");
const handler = (mod as { POST: (req: Request) => Promise<Response> })
.POST;
const chunks: Buffer[] = [];
for await (const c of req) chunks.push(c as Buffer);
const body = chunks.length ? Buffer.concat(chunks) : undefined;
const headers = new Headers();
for (const [k, v] of Object.entries(req.headers)) {
if (Array.isArray(v)) headers.set(k, v.join(", "));
else if (typeof v === "string") headers.set(k, v);
}
const fetchReq = new Request(
`http://localhost${req.url ?? "/api/chat"}`,
{ method: "POST", headers, body },
);
const response = await handler(fetchReq);
res.statusCode = response.status;
response.headers.forEach((value, key) => res.setHeader(key, value));
if (response.body) {
const reader = response.body.getReader();
while (true) {
const { done, value } = await reader.read();
if (done) break;
res.write(Buffer.from(value));
}
}
res.end();
} catch (err) {
console.error("/api/chat error", err);
res.statusCode = 500;
res.end(err instanceof Error ? err.message : "internal error");
}
});
},
};
}
export default defineConfig(({ mode }) => { export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), ""); const env = loadEnv(mode, process.cwd(), "");
for (const k of Object.keys(env)) { for (const k of Object.keys(env)) {
@@ -58,7 +9,7 @@ export default defineConfig(({ mode }) => {
} }
return { return {
plugins: [react(), apiChatPlugin()], plugins: [react()],
resolve: { resolve: {
alias: { alias: {
"@": path.resolve(__dirname, "."), "@": path.resolve(__dirname, "."),