vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.14k stars 6.15k forks source link

Option for generated files not to be appended with hash #6564

Closed patrik-sticha closed 2 years ago

patrik-sticha commented 2 years ago

Clear and concise description of the problem

I would like to use Vite as a build tool not only for standalone apps, but for building assets-only, for example to build CSS and JS files for websites running on PHP with no HTML files. In that case Vite is currently unusable, as it always appends hash to generated files, thus those files can not be hard-linked from outside the Vite project.

Suggested solution

Solution would be to provide an option to vite.config not to use hashes at all and generate file names "as is", without change.

Alternative

No response

Additional context

There have been partial solutions for this issue, but none of those is working on "config-level", or supporting files generated by vite plugins - e.g. vitejs/plugin-legacy, wich makes those solutions unusable as well.

Validations

bluwy commented 2 years ago

You can configure that with build.rollupOptions.assetFileNames and build.rollupOptions.chunkFileNames

patrik-sticha commented 2 years ago

@bluwy Actually I can't, when I use plug-ins like for legacy assets (as mentioned above), resulting files still have the hash appended and there is no option currently to get rid of it.

bluwy commented 2 years ago

According to the code, plugin-legacy should respect the assetFIlesNames and chunkFileNames configuration too though:

https://github.com/vitejs/vite/blob/212d4548eeb366289c6c6fa6f86f94b261ed81f4/packages/plugin-legacy/index.js#L225-L226

Perhaps there's a bug somewhere within it?