Vite plugin
Regenerate canister declarations whenever dfx redeploys, without leaving the dev server running against a stale interface.
Install
Configure
The plugin reads dfx.json for the canister list and the local replica port, so
there is nothing to repeat in the Vite config.
What it emits
One directory per canister, each with the IDL factory, the _SERVICE type and the
canister id for the current network.
That is the shape defineReactor expects, so wiring a new canister is an import:
Watch mode
With watch: true the plugin subscribes to the .did files dfx writes on deploy.
A dfx deploy in another terminal regenerates the declarations and triggers an HMR
update, so a changed method signature becomes a type error in your editor rather
than a rejected call in the browser.
Generated output is not source
Add the output directory to .gitignore and generate in CI. Committing declarations means a stale interface can be merged, and the conflict it causes on every deploy is noise.
Networks
The canister id the plugin writes depends on the network dfx last deployed to. For a build that must target mainnet regardless of local state, pass the network explicitly:
The CLI takes the same flag, for projects not built with Vite.