Migration from v1
-
transforms
jsx
andenableEsbuild
have been removed; Use the new option instead.CSS related options are now nested under
css
.All are now nested under
build
.rollupInputOptions
androllupOutputOptions
are replaced bybuild.rollupOptions
.esbuildTarget
is now .emitManifest
is nowbuild.manifest
.- The following build options have been removed since they can be achieved via plugin hooks or other options:
entry
emitAssets
emitIndex
configureBuild
All are now nested under
server
.hostname
is nowserver.host
.httpsOptions
has been removed. can directly accept the options object.chokidarWatchOptions
is nowserver.watch
.
now expects
string | 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 @vitejs/plugin-react-refresh
.
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.