vite-plugin-openapi-codegen 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -239,6 +239,8 @@ interface Options {
239
239
  pathPrefix?: string;
240
240
  stripPrefix?: boolean;
241
241
  typeAliases?: boolean;
242
+ generateOnDev?: boolean;
243
+ generateOnHmr?: boolean;
242
244
  httpClient?: {
243
245
  module?: string;
244
246
  jsonFunction?: string;
@@ -255,6 +257,14 @@ Path or URL to the OpenAPI JSON/YAML document. Local paths are resolved relative
255
257
 
256
258
  In dev mode, generation errors are logged and do not stop Vite from starting. In build mode, the plugin is skipped entirely.
257
259
 
260
+ ### `generateOnDev`
261
+
262
+ Controls whether the plugin generates artifacts automatically when the Vite dev server starts. The default is `true`. Set it to `false` when you want dev startup to avoid touching generated files and rely on `vg` or another explicit generation step instead. This option only affects the Vite dev lifecycle; the `vg` CLI still generates when invoked.
263
+
264
+ ### `generateOnHmr`
265
+
266
+ Controls whether the plugin regenerates artifacts through Vite HMR when a local OpenAPI input file changes. The default is `true`. Set it to `false` when local spec edits should not automatically rewrite generated files during an active dev session. Online `http://` and `https://` inputs are still not watched.
267
+
258
268
  ### `output`
259
269
 
260
270
  Directory where generated files are written, relative to the Vite project root. The `vg` CLI reads this value from `vite.config.*` when present, unless you override it with `--output`.
package/dist/index.d.mts CHANGED
@@ -78,6 +78,10 @@ interface Options {
78
78
  httpClient?: HttpClientConfig;
79
79
  /** Generate and consume top-level type aliases. Default: false */
80
80
  typeAliases?: boolean;
81
+ /** Whether to generate during Vite dev server startup. Default: true */
82
+ generateOnDev?: boolean;
83
+ /** Whether to regenerate through Vite HMR for local inputs. Default: true */
84
+ generateOnHmr?: boolean;
81
85
  }
82
86
  interface GeneratedArtifacts {
83
87
  api: string;
package/dist/index.mjs CHANGED
@@ -677,12 +677,13 @@ function openapiCodegen(options) {
677
677
  command = config.command;
678
678
  },
679
679
  async buildStart() {
680
- if (command === "serve") {
680
+ if (command === "serve" && options.generateOnDev !== false) {
681
681
  runDevelopmentGeneration(root, options);
682
682
  return;
683
683
  }
684
684
  },
685
685
  async handleHotUpdate(ctx) {
686
+ if (options.generateOnHmr === false) return;
686
687
  if (isHttpUrl(options.input)) return;
687
688
  const inputPath = resolve(root, options.input);
688
689
  if (resolve(ctx.file) !== inputPath) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-openapi-codegen",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Vite plugin that generates typed API clients and route builders from OpenAPI specs",
5
5
  "keywords": [
6
6
  "api-client",