|
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)); |
|
|
|
|
|
async function tryImport(moduleName: string, fallback = null) { |
|
try { |
|
return await import(moduleName); |
|
} catch { |
|
return fallback; |
|
} |
|
} |
|
|
|
export default defineConfig(async () => { |
|
const plugins = [react()]; |
|
|
|
|
|
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: ["**/.*"], |
|
}, |
|
}, |
|
}; |
|
}); |
|
|