Gradle/npm command to generate vite.generated

Hi,

I am adding storybooks to our project and to build it Vite requires the file vite.generated.ts to be there. I was trying multiple Gradle goals here to generate that file, but apparently it is only generated when I run the development mode. Even when I compile with the production command it does not generate it.

Thanks for your time.

Why aren’t you persisting it to your git repository?

Good question,

by default, in the generated project it is in gitignore. If there are no constraints, I could indeed do it.

I don’t think you can commit it because it also depends on generated files in the build folder.

I see on top of the file the following comment:

[11:25] Thiago Vidigal

/** 
  * NOTICE: this is an auto-generated file 
  *
  * This file has been generated by the `flow:prepare-frontend` maven goal. 
  * This file will be overwritten on every run. Any custom changes should be made to vite.config.ts 
  */

But when I run the gradle equivalent ./gradlew vaadinPrepareFrontend it does not get generated.

Mine is committed since day 1; the only time it changes is when I update vaadin.

For the storybooks pipeline we ended up just deleting the vite.config.ts. If we need something there in the future, we might create a specific one.

Committing just the generated file would not be enough, given the dependencies it has on the build folder.

I have exactly the same problem, and just committing the “vite.generated.ts” doesn’t solve the problem because it references some files from the “build” folder. In this case, I would need to commit them as well, which is already too much.

The only way I found to generate that code is to run an application, but that’s not an option in a build pipeline.

Here are my errors:

✘ [ERROR] Could not resolve "./build/plugins/application-theme-plugin/theme-handle.js"
    vite.generated.ts:12:38:
      12 │ import { processThemeResources } from './build/plugins/application-theme-plugin/theme-handle.js';         ╵                                       
✘ [ERROR] Could not resolve "./build/plugins/theme-loader/theme-loader-utils.js"
    vite.generated.ts:13:31:
      13 │ import { rewriteCssUrls } from './build/plugins/theme-loader/theme-loader-utils.js';
✘ [ERROR] Could not resolve "./build/plugins/rollup-plugin-postcss-lit-custom/rollup-plugin-postcss-lit.js"
    vite.generated.ts:31:23:
      31 │ import postcssLit from './build/plugins/rollup-plugin-postcss-lit-custom/rollup-plugin-postcss-lit.js';