Edit

+precompress

Environment: config (build)
type Value = boolean // Default: `false`

Global

The +precompress setting creates .br and .gz files for your static assets at build time, so that they don't have to be compressed on each request.

// pages/+config.js
 
export default {
  precompress: true
}
// pages/+config.ts
 
import type { Config } from 'vike/types'
 
export default {
  precompress: true
} satisfies Config
dist/client/assets/chunks/chunk-C7ohsKGx.js
dist/client/assets/chunks/chunk-C7ohsKGx.js.br
dist/client/assets/chunks/chunk-C7ohsKGx.js.gz

The +precompress setting is usually used when self-hosting — with most managed hosting platforms (Cloudflare, Vercel, Netlify, ...), you don't need +precompress: static assets are compressed by the platform.

Small files, and files that are already compressed (such as .png, .jpg and .woff2), don't get .br/.gz files.

Serving

If you use +server, the .br/.gz files are served automatically.

If you use your own server, make sure your server serves them. For example with sirv:

sirv('dist/client', { brotli: true, gzip: true })

Likewise, if you use +server with prod.static set to false, then make sure your static server serves the .br/.gz files.

public/

Files in public/ are copied as-is and don't get .br/.gz files. If you add your own .br/.gz, they're served, but keeping them up-to-date is up to you.

See also