61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
import path from "path";
|
|
import runtimeErrorOverlay from "@replit/vite-plugin-runtime-error-modal";
|
|
import { mockupPreviewPlugin } from "./mockupPreviewPlugin";
|
|
|
|
const rawPort = process.env.PORT ?? "3001";
|
|
|
|
const port = Number(rawPort);
|
|
|
|
if (Number.isNaN(port) || port <= 0) {
|
|
throw new Error(`Invalid PORT value: "${rawPort}"`);
|
|
}
|
|
|
|
const basePath = process.env.BASE_PATH ?? "/";
|
|
|
|
export default defineConfig({
|
|
base: basePath,
|
|
plugins: [
|
|
mockupPreviewPlugin(),
|
|
react(),
|
|
tailwindcss(),
|
|
runtimeErrorOverlay(),
|
|
...(process.env.NODE_ENV !== "production" &&
|
|
process.env.REPL_ID !== undefined
|
|
? [
|
|
await import("@replit/vite-plugin-cartographer").then((m) =>
|
|
m.cartographer({
|
|
root: path.resolve(import.meta.dirname, ".."),
|
|
}),
|
|
),
|
|
]
|
|
: []),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(import.meta.dirname, "src"),
|
|
},
|
|
},
|
|
root: path.resolve(import.meta.dirname),
|
|
build: {
|
|
outDir: path.resolve(import.meta.dirname, "dist"),
|
|
emptyOutDir: true,
|
|
},
|
|
server: {
|
|
port,
|
|
host: "0.0.0.0",
|
|
allowedHosts: true,
|
|
fs: {
|
|
strict: true,
|
|
deny: ["**/.*"],
|
|
},
|
|
},
|
|
preview: {
|
|
port,
|
|
host: "0.0.0.0",
|
|
allowedHosts: true,
|
|
},
|
|
});
|