How to remove hashing in Vite built file names
Posted on December 15, 2022
After some research, here the configuration that you need to add in your vite.config.js
file in order to remove hashing in the built js
and css
file:
export default defineConfig({
...
build: {
rollupOptions: {
output: {
entryFileNames: `assets/[name].js`,
chunkFileNames: `assets/[name].js`,
assetFileNames: `assets/[name].[ext]`
}
}
}
})
So, instead of:
dist/index-shegty45.js
dist/index-bfjgney5.css
You'll get:
dist/index.js
dist/index.css
This is quite handy if your dependencies need the same filename across builds.