52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { defineConfig } from "vitest/config";
|
|
import react from "@vitejs/plugin-react";
|
|
|
|
const packageVersion = (JSON.parse(readFileSync(new URL("./package.json", import.meta.url), "utf8")) as { version: string }).version;
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const androidBuild = mode === "android";
|
|
return {
|
|
plugins: [react()],
|
|
publicDir: androidBuild ? ".android-public" : "public",
|
|
define: {
|
|
"import.meta.env.VITE_APP_VERSION": JSON.stringify(packageVersion),
|
|
"import.meta.env.VITE_CONTENT_MODE": JSON.stringify(androidBuild ? "downloadable" : "bundled"),
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"@dungeonAssetModules": path.resolve(
|
|
androidBuild ? "src/game/dungeonAssetModules.android.ts" : "src/game/dungeonAssetModules.ts",
|
|
),
|
|
},
|
|
},
|
|
server: {
|
|
proxy: {
|
|
"/api": "http://127.0.0.1:4173",
|
|
"/content": "http://127.0.0.1:4173",
|
|
},
|
|
watch: {
|
|
// Asset-pipeline staging files are large, short-lived, and can be locked
|
|
// while iCloud or conversion tools are writing them. They are not app
|
|
// source, so watching them only risks taking the dev server down with
|
|
// EBUSY on Windows.
|
|
ignored: [
|
|
"**/dungeon-pipeline/**",
|
|
"**/playtest-artifacts/**",
|
|
],
|
|
},
|
|
},
|
|
build: {
|
|
target: "es2022",
|
|
sourcemap: false,
|
|
emptyOutDir: true,
|
|
outDir: androidBuild ? "dist-android" : "dist",
|
|
},
|
|
test: {
|
|
environment: "node",
|
|
include: ["src/**/*.test.ts"],
|
|
},
|
|
};
|
|
});
|