跳转到内容
Host your specs. Generate from anywhere.

Vite

此内容尚不支持你的语言。

Vite is a blazing fast frontend build tool powering the next generation of web applications.

The Vite plugin integrates @hey-api/openapi-ts into the Vite build pipeline, running automatically whenever Vite resolves its configuration – no separate script or manual step required.

  • runs automatically as part of your Vite build
  • reads your existing configuration (or accepts inline config)
  • supports Vite 5, 6, 7, and 8

You can download @hey-api/vite-plugin from npm using your favorite package manager.

Terminal window
npm install @hey-api/vite-plugin -D -E

Add the plugin to your vite.config.ts:

vite.config.ts
import { heyApiPlugin } from '@hey-api/vite-plugin';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [heyApiPlugin()],
});

The plugin will automatically pick up your configuration file. You can also pass options inline using the config option:

vite.config.ts
import { heyApiPlugin } from '@hey-api/vite-plugin';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
heyApiPlugin({
config: {
input: 'hey-api/backend', // sign up at app.heyapi.dev
output: 'src/client',
},
}),
],
});

You can pass Vite Plugin API options using the vite option. For example, to run the plugin only during development:

vite.config.ts
import { heyApiPlugin } from '@hey-api/vite-plugin';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
heyApiPlugin({
config: {
input: 'hey-api/backend', // sign up at app.heyapi.dev
output: 'src/client',
},
vite: {
apply: 'serve',
},
}),
],
});

Examples

You can view live examples on StackBlitz or on GitHub.