new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Vite · Config reference · all subjects

build options - core output

14 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Default build entry point

By default, Vite uses <root>/index.html as the build entry point.

Default browser compatibility targets

By default, the production bundle targets the minimum browser versions compatible with Baseline Widely Available. The default browser support range is: Chrome >=111, Edge >=111, Firefox >=114, Safari >=16.4.

build.target configuration option

The build.target config option allows you to specify custom targets for browser compatibility. The lowest target is es2015. If a lower target is set, Vite still requires minimum browser support ranges of Chrome >=64, Firefox >=67, Safari >=11.1, Edge >=79 because it relies on native ESM dynamic import and import.meta.

Vite does not handle polyfills by default

By default, Vite only handles syntax transforms and does not cover polyfills. Legacy browsers can be supported via @vitejs/plugin-legacy, which automatically generates legacy chunks and corresponding ES language feature polyfills.

import.meta.env.BASE_URL variable

The globally injected import.meta.env.BASE_URL variable contains the public base path. This variable is statically replaced during build and must appear exactly as-is (import.meta.env['BASE_URL'] will not work). It is useful for dynamically concatenating URLs on the fly.

build.rolldownOptions configuration

You can adjust the underlying Rolldown options via build.rolldownOptions. This allows you to specify multiple Rolldown outputs and plugins that are only applied during build.

build.rolldownOptions.output.codeSplitting for chunking

Code splitting strategy can be configured using build.rolldownOptions.output.codeSplitting. Refer to Rolldown documentation for manual code splitting options.

vite:preloadError event for load error handling

Vite emits a vite:preloadError event when it fails to load dynamic imports. The event.payload contains the original import error. Calling event.preventDefault() prevents the error from being thrown. This is useful for handling outdated assets after deployment.

build.watch for rebuild on file changes

You can enable Rolldown watcher with vite build --watch. The build.watch option allows direct adjustment of underlying WatcherOptions from Rolldown. Changes to files trigger a rebuild, but changes to config and its dependencies require restarting the build command.

Multi-page app with multiple HTML entry points

For multi-page apps, you can specify multiple .html files as entry points in the build.input configuration object. Vite ignores the name given to entries in rolldownOptions.input and instead respects the resolved file id when generating HTML assets in the dist folder.

experimental.renderBuiltUrl for advanced base options

The experimental.renderBuiltUrl option (experimental feature) provides advanced control over asset URL generation during build. It accepts a function with parameters (filename, { hostId, hostType, type }) that returns either a URL string or an object with runtime property for dynamic URL generation.

renderBuiltUrl context parameters

The renderBuiltUrl function receives context parameters: hostId (the file requesting the asset), hostType (either 'js' or 'html'), and type (asset type: 'public' or other). This allows per-type configuration for different deployment strategies.

renderBuiltUrl filename encoding

The filename parameter passed to renderBuiltUrl is a decoded URL. If the function returns a URL string, it should also be decoded. Vite handles encoding automatically when rendering. If an object with runtime is returned, encoding must be handled in the runtime code.

Multi-page app import.meta.dirname usage

When configuring multiple .html entry points with build.input, import.meta.dirname refers to the folder of vite.config.js. If using a different root, add the root entry to the resolve arguments.

Give your agent this brain