46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { fileURLToPath } from "node:url";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import { defineConfig, configDefaults } from "vitest/config";
|
|
import type { UserConfig } from "vite";
|
|
|
|
export function createDevServerConfig(
|
|
env: NodeJS.ProcessEnv = process.env,
|
|
): UserConfig["server"] {
|
|
const apiTarget = env.DASHBOARD_DEV_API_TARGET;
|
|
if (!apiTarget) return undefined;
|
|
|
|
return {
|
|
proxy: {
|
|
"/api": {
|
|
target: apiTarget,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [react(), tailwindcss()],
|
|
resolve: {
|
|
alias: {
|
|
"@dimensionlab/ui/styles.css": fileURLToPath(
|
|
new URL("../../packages/ui/src/styles.css", import.meta.url),
|
|
),
|
|
"@dimensionlab/ui": fileURLToPath(
|
|
new URL("../../packages/ui/src/index.ts", import.meta.url),
|
|
),
|
|
"@dimensionlab/dashboard-model/fixtures": fileURLToPath(
|
|
new URL("../../packages/dashboard-model/src/fixtures/index.ts", import.meta.url),
|
|
),
|
|
"@dimensionlab/dashboard-model": fileURLToPath(
|
|
new URL("../../packages/dashboard-model/src/index.ts", import.meta.url),
|
|
),
|
|
$lib: fileURLToPath(new URL("./src/lib", import.meta.url)),
|
|
},
|
|
},
|
|
server: createDevServerConfig(),
|
|
test: {
|
|
exclude: [...configDefaults.exclude, "tests/e2e/**"],
|
|
},
|
|
});
|