diff --git a/bun.lockb b/bun.lockb index 4ade719b..9c4e65df 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/index.ts b/index.ts index 031db5b3..bb4270a4 100644 --- a/index.ts +++ b/index.ts @@ -135,6 +135,15 @@ Bun.serve({ return await file.default(req.clone(), matchedRoute, auth); } else { + // Proxy response from Vite at localhost:5173 + const proxy = await fetch( + req.url.replace(config.http.base_url, "http://localhost:5173") + ); + + if (proxy.status !== 404) { + return proxy; + } + return new Response(undefined, { status: 404, statusText: "Route not found", diff --git a/package.json b/package.json index f0dc9443..62ddf26c 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "private": true, "scripts": { "dev": "bun run index.ts", + "vite:dev": "bunx --bun vite pages", "start": "bun run index.ts", "migrate-dev": "bun prisma migrate dev", "migrate": "bun prisma migrate deploy", @@ -74,6 +75,8 @@ "dependencies": { "@aws-sdk/client-s3": "^3.461.0", "@prisma/client": "^5.6.0", + "@vitejs/plugin-vue": "^4.5.1", + "@vueuse/head": "^2.0.0", "blurhash": "^2.0.5", "bullmq": "^4.14.4", "chalk": "^5.3.0", @@ -94,6 +97,10 @@ "prisma": "^5.6.0", "prisma-redis-middleware": "^4.8.0", "semver": "^7.5.4", - "sharp": "^0.33.0-rc.2" + "sharp": "^0.33.0-rc.2", + "vite": "^5.0.4", + "vue": "^3.3.9", + "vue-router": "^4.2.5", + "vue-tsc": "^1.8.24" } } \ No newline at end of file diff --git a/pages/App.vue b/pages/App.vue new file mode 100644 index 00000000..1e5d5a5f --- /dev/null +++ b/pages/App.vue @@ -0,0 +1,8 @@ + + + \ No newline at end of file diff --git a/pages/index.html b/pages/index.html new file mode 100644 index 00000000..03a73837 --- /dev/null +++ b/pages/index.html @@ -0,0 +1,16 @@ + + + + + + + + Vite + Vue + TS + + + +
+ + + + \ No newline at end of file diff --git a/pages/login.html b/pages/login.html deleted file mode 100644 index 4eb3abf5..00000000 --- a/pages/login.html +++ /dev/null @@ -1,445 +0,0 @@ - - - - Login with Lysand - {{STYLES}} - - - - - -
-
-
-
- -
- -
-
- -
-
- -
-
- -
-
- -
- -
-
-
-
- \ No newline at end of file diff --git a/pages/login.vue b/pages/login.vue new file mode 100644 index 00000000..7632b80e --- /dev/null +++ b/pages/login.vue @@ -0,0 +1,42 @@ + + + \ No newline at end of file diff --git a/pages/main.ts b/pages/main.ts new file mode 100644 index 00000000..d48aedce --- /dev/null +++ b/pages/main.ts @@ -0,0 +1,22 @@ +import { createApp } from "vue"; +import "./style.css"; +import { createRouter, createWebHistory } from "vue-router"; +import Login from "./login.vue"; +import App from "./App.vue"; + +const Home = { template: "
Home
" }; + +const routes = [ + { path: "/", component: Home }, + { path: "/oauth/login", component: Login }, +]; + +const router = createRouter({ + history: createWebHistory(), + routes, +}); + +const app = createApp(App); +app.use(router); + +app.mount("#app"); diff --git a/pages/style.css b/pages/style.css new file mode 100644 index 00000000..e69de29b diff --git a/pages/vite-env.d.ts b/pages/vite-env.d.ts new file mode 100644 index 00000000..11f02fe2 --- /dev/null +++ b/pages/vite-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/pages/vite.config.ts b/pages/vite.config.ts new file mode 100644 index 00000000..d94dfe72 --- /dev/null +++ b/pages/vite.config.ts @@ -0,0 +1,30 @@ +import { defineConfig } from "vite"; +import UnoCSS from "unocss/vite"; +import vue from "@vitejs/plugin-vue"; + +export default defineConfig({ + base: "/", + build: { + outDir: "../vite-dist", + }, + // main.ts is in pages/ directory + resolve: { + alias: { + vue: "vue/dist/vue.esm-bundler", + }, + }, + server: { + hmr: { + clientPort: 5173, + }, + }, + ssr: { + noExternal: ["@prisma/client"], + }, + plugins: [ + UnoCSS({ + mode: "vue-scoped", + }), + vue(), + ], +}); diff --git a/tsconfig.json b/tsconfig.json index 1461898f..d68e047c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,7 +31,9 @@ }, "include": [ "*.ts", + "*.vue", "**/*.ts", + "**/*.vue", "server/api/.well-known/**/*.ts" ] }