vite build (usually via npm run build).
Build stages
Firstly, Vite creates an optimized production build of your server code, your browser code, and your service worker (if you have one). Prerendering (routes marked withexport const prerender = true) is executed at this stage, if appropriate.
Secondly, an adapter takes this production build and tunes it for your target environment. See the adapters overview for more information.
During the build
SvelteKit will load your+page/layout(.server).js files (and all files they import) for analysis during the build. Any code that should not be executed at this stage must check that building from $app/environment is false:
The
building flag is only true during the build process. It’s false during development and when your app is running in production.Preview your app
After building, you can view your production build locally withvite preview (via npm run preview).
Build output
The build process creates several directories and files:1
Client assets
Optimized JavaScript, CSS, and other static assets for the browser
2
Server bundle
Server-side rendering code and API routes
3
Prerendered pages
Static HTML files for routes marked with
export const prerender = true4
Adapter output
Platform-specific files generated by your chosen adapter
Build configuration
You can customize the build process through yoursvelte.config.js file: