55 lines
1.2 KiB
JavaScript
55 lines
1.2 KiB
JavaScript
// Custom Vite server configuration
|
|
// Use dynamic imports for ES modules
|
|
const vite = await import("vite");
|
|
const reactPlugin = await import("@vitejs/plugin-react");
|
|
const fs = await import("fs");
|
|
const path = await import("path");
|
|
|
|
// Create and configure the server
|
|
async function startServer() {
|
|
const server = await vite.createServer({
|
|
// Configure plugins
|
|
plugins: [reactPlugin.default()],
|
|
|
|
// Configure server options
|
|
server: {
|
|
port: 3000,
|
|
strictPort: true,
|
|
|
|
// Configure MIME types
|
|
middlewareMode: false,
|
|
},
|
|
|
|
// Configure optimizations
|
|
optimizeDeps: {
|
|
include: ["react", "react-dom", "react-router-dom"],
|
|
},
|
|
|
|
// Configure build options
|
|
build: {
|
|
outDir: "dist",
|
|
assetsDir: "assets",
|
|
emptyOutDir: true,
|
|
},
|
|
|
|
// Configure resolve options
|
|
resolve: {
|
|
extensions: [".jsx", ".js", ".ts", ".tsx"],
|
|
},
|
|
});
|
|
|
|
// Start the server
|
|
await server.listen();
|
|
|
|
// Log server info
|
|
console.log(`Server running at: ${server.resolvedUrls.local[0]}`);
|
|
|
|
return server;
|
|
}
|
|
|
|
// Start the server
|
|
startServer().catch((err) => {
|
|
console.error("Failed to start server:", err);
|
|
process.exit(1);
|
|
});
|