Migration from v1
-
transforms
jsx
andenableEsbuild
have been removed; Use the newesbuild
option instead.are now nested under
css
.All build-specific options are now nested under
build
.rollupInputOptions
androllupOutputOptions
are replaced by .esbuildTarget
is nowbuild.target
.emitManifest
is now .- The following build options have been removed since they can be achieved via plugin hooks or other options:
entry
emitAssets
emitIndex
configureBuild
All server-specific options are now nested under
server
.hostname
is now .httpsOptions
has been removed.server.https
can directly accept the options object.chokidarWatchOptions
is now .
assetsInclude
now expectsstring | RegExp | (string | RegExp)[]
instead of a function.
Alias Behavior Change
alias
is now being passed to @rollup/plugin-alias
and no longer require start/ending slashes. The behavior is now a direct replacement, so 1.0-style directory alias key should remove the ending slash:
Alternatively, you can use the option format for more precise control.
Vite 2.0 core is now framework agnostic. Vue support is now provided via . Simply install it and add it in the Vite config:
A custom plugin can be used to transform Vue custom blocks like the one below:
React Support
React Fast Refresh support is now provided via .
Manifest Format Change
The build manifest now uses the following format:
For entry JS chunks, it also lists its imported chunks which can be used to render preload directives.
Vite 2 uses a completely redesigned plugin interface which extends Rollup plugins. Please read the new .
Some general pointers on migrating a v1 plugin to v2:
resolvers
-> use theresolveId
hooktransforms
-> use the hookindexHtmlTransforms
-> use thetransformIndexHtml
hook- Serving virtual files -> use +
load
hooks
Since most of the logic should be done via plugin hooks instead of middlewares, the need for middlewares is greatly reduced. The internal server app is now a good old instance instead of Koa.