❌ Wrong setup
Vite should only be loaded in development (or when building). Loading it in production is unnecessary and significantly bloats the production process.
In production:
- Make sure you don't load the
vitepackage nor Vike's Vite plugin. - Make sure you don't call
createDevMiddleware(). (The development middleware isn't needed in production.)You can import
createDevMiddlewarein production, but make sure you don't call it.// Environment: production import { createDevMiddleware } from 'vike/server' // ✅ You can import it createDevMiddleware() // ❌ You shouldn't call it
In development, if you use a server without vike-photon (i.e. you manually integrate your server), you must use createDevMiddleware() in order to add the development middleware to your server. (If you use vike-photon, the development middleware is added automatically and you don't need to use createDevMiddleware().)