← Workers / workers / vite-plugin / reference
Migrating from wrangler dev
In most cases, migrating from wrangler dev is straightforward and you can follow the instructions in Get started.
There are a few key differences to highlight:
Input and output Worker config files
With the Cloudflare Vite plugin, your Worker config file (for example, wrangler.jsonc) is the input configuration and a separate output configuration is created as part of the build.
This output file is a snapshot of your configuration at the time of the build and is modified to reference your build artifacts.
It is the configuration that is used for preview and deployment.
Once you have run vite build, running wrangler deploy or vite preview will automatically locate this output configuration file.
Cloudflare Environments
With the Cloudflare Vite plugin, Cloudflare Environments are applied at dev and build time.
Running wrangler deploy --env some-env is therefore not applicable and the environment to deploy should instead be set by running CLOUDFLARE_ENV=some-env vite build.
Redundant fields in the Wrangler config file
There are various options in the Worker config file that are ignored when using Vite, as they are either no longer applicable or are replaced by Vite equivalents. If these options are provided, then warnings will be printed to the console with suggestions for how to proceed.
Not applicable
The following build-related options are handled by Vite and are not applicable when using the Cloudflare Vite plugin:
tsconfigrulesbuildno_bundlefind_additional_modulesbase_dirpreserve_file_names
Not supported
site— Use Workers Assets instead.
Replaced by Vite equivalents
The following options have Vite equivalents that should be used instead:
| Wrangler option | Vite equivalent |
|---|---|
define |
define ↗ |
alias |
resolve.alias ↗ |
minify |
build.minify ↗ |
Local dev settings (ip, port, local_protocol, etc.) |
Server options ↗ |
See Vite Environments for more information about configuring your Worker environments in Vite.
Inferred
If build.sourcemap ↗ is enabled for a given Worker environment in the Vite config, "upload_source_maps": true is automatically added to the output Wrangler configuration file.
This means that generated sourcemaps are uploaded by default.
To override this setting, you can set the value of upload_source_maps explicitly in the input Worker config.