diff --git a/.gitignore b/.gitignore index baf4031..8fa56cd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* pnpm-debug.log* +.deploy/ +public/*.html diff --git a/package-lock.json b/package-lock.json index 4f3b2f5..7aee627 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,8 +7,10 @@ "": { "name": "red-bull-intake-tracker", "version": "1.0.0", + "license": "MIT", "dependencies": { "@vitejs/plugin-react": "^4.3.4", + "@zxing/browser": "^0.2.0", "appwrite": "^25.0.0", "exceljs": "^4.4.0", "framer-motion": "^11.18.2", @@ -1898,6 +1900,41 @@ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, + "node_modules/@zxing/browser": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/@zxing/browser/-/browser-0.2.0.tgz", + "integrity": "sha512-+ORhrLva0vm6ck74NDCmvYNW3XLoAG81Mu90qfcssN1PBKJjQadxZGeMCcIk+BdJbD/zEAjjHDXOwEK1QCmRtw==", + "license": "MIT", + "optionalDependencies": { + "@zxing/text-encoding": "^0.9.0" + }, + "peerDependencies": { + "@zxing/library": "^0.22.0" + } + }, + "node_modules/@zxing/library": { + "version": "0.22.0", + "resolved": "https://registry.npmjs.org/@zxing/library/-/library-0.22.0.tgz", + "integrity": "sha512-BmInervZV7NwaZWX1LW64sZ4Lh4wxXYFZwGmj98ArPOkRXCtO9b8Gog0Xyh82dsYYGOeRxX+aAhLSq+hQ2XLZQ==", + "license": "Apache-2.0", + "peer": true, + "dependencies": { + "ts-custom-error": "^3.3.1" + }, + "engines": { + "node": ">= 24.0.0" + }, + "optionalDependencies": { + "@zxing/text-encoding": "~0.9.0" + } + }, + "node_modules/@zxing/text-encoding": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", + "integrity": "sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==", + "license": "(Unlicense OR Apache-2.0)", + "optional": true + }, "node_modules/acorn": { "version": "8.16.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", @@ -5079,6 +5116,16 @@ "typescript": ">=4.8.4" } }, + "node_modules/ts-custom-error": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/ts-custom-error/-/ts-custom-error-3.3.1.tgz", + "integrity": "sha512-5OX1tzOjxWEgsr/YEUWSuPrQ00deKLh6D7OTWcvNHm12/7QPyRh8SYpyWvA4IZv8H/+GQWQEh/kwo95Q9OVW1A==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/ts-interface-checker": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", diff --git a/package.json b/package.json index 7fec1a0..7e7fec6 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "red-bull-intake-tracker", "private": true, "version": "1.0.0", + "license": "MIT", "type": "module", "scripts": { "dev": "vite", @@ -12,6 +13,7 @@ }, "dependencies": { "@vitejs/plugin-react": "^4.3.4", + "@zxing/browser": "^0.2.0", "appwrite": "^25.0.0", "exceljs": "^4.4.0", "framer-motion": "^11.18.2", diff --git a/vite.config.ts b/vite.config.ts index e45d38c..9bfe18e 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,44 +1,37 @@ +import { existsSync, readFileSync } from "node:fs"; import react from "@vitejs/plugin-react"; -import { defineConfig, loadEnv } from "vite"; +import type { Plugin } from "vite"; +import { defineConfig } from "vite"; -export default defineConfig(({ mode }) => { - const env = loadEnv(mode, process.cwd(), ""); - const ollamaProxy = { - target: "https://ollama.com", - changeOrigin: true, - rewrite: () => "/api/chat", - configure(proxy: { on: (event: "proxyReq", handler: (proxyReq: { setHeader: (name: string, value: string) => void }) => void) => void }) { - proxy.on("proxyReq", (proxyReq) => { - if (env.OLLAMA_API_KEY) { - proxyReq.setHeader("Authorization", `Bearer ${env.OLLAMA_API_KEY}`); - } - }); - }, - }; - - return { - plugins: [react()], - server: { - proxy: { - "/api/ollama-chat": ollamaProxy, - }, - }, - preview: { - proxy: { - "/api/ollama-chat": ollamaProxy, - }, - }, - build: { - chunkSizeWarningLimit: 700, - rollupOptions: { - output: { - manualChunks: { - charts: ["recharts"], - motion: ["framer-motion"], - icons: ["lucide-react"], - }, +export default defineConfig(({ command }) => ({ + plugins: [react(), deploymentHtml(command === "build")], + build: { + chunkSizeWarningLimit: 700, + rollupOptions: { + output: { + manualChunks: { + charts: ["recharts"], + motion: ["framer-motion"], + icons: ["lucide-react"], }, }, }, + }, +})); + +function deploymentHtml(enabled: boolean): Plugin { + return { + name: "deployment-html", + transformIndexHtml(html) { + if (!enabled) return html; + return html + .replace("", `${readOptional(".deploy/head.html")}`) + .replace("", `${readOptional(".deploy/body-end.html")}`); + }, }; -}); +} + +function readOptional(path: string) { + if (!existsSync(path)) return ""; + return `\n${readFileSync(path, "utf8").trim()}\n`; +}