File size: 1,464 Bytes
7c012de 7127914 7c012de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import { fileURLToPath } from "url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
// Helper function to safely import optional plugins
async function tryImport(moduleName: string, fallback = null) {
try {
return await import(moduleName);
} catch {
return fallback;
}
}
export default defineConfig(async () => {
const plugins = [react()];
// Add Replit plugins only in development and when running on Replit
if (process.env.NODE_ENV === "development" && process.env.REPL_ID !== undefined) {
const runtimeErrorOverlay = await tryImport("@replit/vite-plugin-runtime-error-modal");
if (runtimeErrorOverlay) {
plugins.push(runtimeErrorOverlay.default());
}
const cartographer = await tryImport("@replit/vite-plugin-cartographer");
if (cartographer) {
plugins.push(cartographer.cartographer());
}
}
return {
plugins,
resolve: {
alias: {
"@": path.resolve(__dirname, "client", "src"),
"@shared": path.resolve(__dirname, "shared"),
"@assets": path.resolve(__dirname, "attached_assets"),
},
},
root: path.resolve(__dirname, "client"),
build: {
outDir: path.resolve(__dirname, "dist/public"),
emptyOutDir: true,
},
server: {
fs: {
strict: true,
deny: ["**/.*"],
},
},
};
});
|