To change Vite's asset naming scheme and ensure that the output file names remain consistent between builds, you can configure the build.rollupOptions.output option in your vite.config.js file. Specifically, you can set the entryFileNames option to a fixed name.
Here's how you can do it:
// vite.config.js
import { defineConfig } from 'vite';
export default defineConfig({
build: {
rollupOptions: {
output: {
entryFileNames: 'myfile.js', // Set a fixed name for the entry file
// You can also set fixed names for other types of assets if needed
// chunkFileNames: 'chunk-[name].js',
// assetFileNames: 'asset-[name].[ext]'
}
}
}
});
This configuration will ensure that the main entry file is always named myfile.js in the production build, preventing the name from changing between builds. Note that this approach is suitable when you have a single entry point or when you want to control the naming of specific entry points. If you have multiple entry points, you might need to adjust the naming pattern accordingly.