| import { defineConfig } from "vite"; |
| import react from "@vitejs/plugin-react"; |
| import tailwindcss from "@tailwindcss/vite"; |
| import path from "path"; |
|
|
| function errorReporterPlugin() { |
| return { |
| name: 'error-reporter', |
| transformIndexHtml(html) { |
| return html.replace( |
| '<div id="root"></div>', |
| `<div id="root"></div> |
| <script> |
| var _errs = []; |
| window.addEventListener('error', function(e) { |
| _errs.push(e.message + ' @ ' + e.filename + ':' + e.lineno); |
| if (_errs.length === 1) { |
| setTimeout(function() { |
| if (!document.getElementById('root').children.length) { |
| var d = document.createElement('pre'); |
| d.style.cssText = 'position:fixed;top:0;left:0;right:0;z-index:99999;background:black;color:lime;padding:1em;font-size:11px;overflow:auto;max-height:30vh;white-space:pre-wrap'; |
| d.textContent = 'Errors (' + _errs.length + '):\\n' + _errs.join('\\n'); |
| document.body.prepend(d); |
| } |
| }, 5000); |
| } |
| e.preventDefault(); |
| return true; |
| }, true); |
| window.addEventListener('unhandledrejection', function(e) { |
| _errs.push('Promise: ' + (e.reason && e.reason.message || e.reason)); |
| e.preventDefault(); |
| }); |
| </script>` |
| ); |
| }, |
| }; |
| } |
|
|
| export default defineConfig({ |
| plugins: [ |
| errorReporterPlugin(), |
| react(), |
| tailwindcss(), |
| ], |
| resolve: { |
| alias: { |
| "@": path.resolve(__dirname, "src"), |
| }, |
| }, |
| root: ".", |
| base: "/vessels/", |
| server: { |
| host: "0.0.0.0", |
| port: 9090, |
| allowedHosts: true, |
| }, |
| build: { |
| outDir: "dist", |
| sourcemap: true, |
| }, |
| optimizeDeps: { |
| include: [ |
| "react", |
| "react-dom", |
| "react-dom/client", |
| "react/jsx-runtime", |
| "react/jsx-dev-runtime", |
| "framer-motion", |
| "lucide-react", |
| "wouter", |
| "@tanstack/react-query", |
| "@tanstack/query-persist-client-core", |
| "@tanstack/query-sync-storage-persister", |
| "recharts", |
| "mapbox-gl", |
| "sonner", |
| ], |
| }, |
| }); |
|
|