mirror of
https://github.com/Xevion/banner.git
synced 2026-01-31 14:23:36 -06:00
51 lines
1.1 KiB
TypeScript
51 lines
1.1 KiB
TypeScript
import { sveltekit } from "@sveltejs/kit/vite";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import { defineConfig } from "vite";
|
|
import { resolve } from "node:path";
|
|
import { readFileSync, existsSync } from "node:fs";
|
|
|
|
function getVersion() {
|
|
const filename = "Cargo.toml";
|
|
const paths = [resolve(__dirname, filename), resolve(__dirname, "..", filename)];
|
|
|
|
for (const path of paths) {
|
|
try {
|
|
if (!existsSync(path)) continue;
|
|
const content = readFileSync(path, "utf8");
|
|
const match = content.match(/^version\s*=\s*"([^"]+)"/m);
|
|
if (match) return match[1];
|
|
} catch {
|
|
// Continue to next path
|
|
}
|
|
}
|
|
|
|
return "unknown";
|
|
}
|
|
|
|
const version = getVersion();
|
|
|
|
export default defineConfig({
|
|
plugins: [tailwindcss(), sveltekit()],
|
|
test: {
|
|
globals: true,
|
|
environment: "jsdom",
|
|
include: ["src/**/*.test.ts"],
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
proxy: {
|
|
"/api": {
|
|
target: "http://localhost:8080",
|
|
changeOrigin: true,
|
|
secure: false,
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
sourcemap: true,
|
|
},
|
|
define: {
|
|
__APP_VERSION__: JSON.stringify(version),
|
|
},
|
|
});
|