Fresh logo

Deployment

When shipping an app to production, we can run a build step that optimizes assets for consumption in the browser. First, make sure dependencies are installed:

Terminal (Shell/Bash) Terminal
deno install --allow-scripts

Then run the build:

Terminal (Shell/Bash) Terminal
deno task build
Info

This runs vite build under the hood. If you’re migrating from Fresh 1.x and still have a dev.ts file, see the migration guide for updating your tasks.

Once completed, it will have created a _fresh folder in the project directory which contains the optimized assets.

Info

The _fresh folder should not be committed to git. Exclude it via .gitignore.

Git .gitignore
# Ignore fresh build directory
_fresh/

Running a production build

To run Fresh in production mode, run the start task:

Terminal (Shell/Bash) Terminal
deno task start

This runs deno serve -A _fresh/server.js, which serves the built assets directly. Fresh will automatically pick up the optimized assets in the _fresh directory.