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:Build configuration
You can customize the build process through yoursvelte.config.js file: