vite-public-resource-hash
v1.0.1
Published
This Vite plugin replaces __content_hash__ in public resources with actual hashes.
Downloads
83
Maintainers
Readme
vite-public-resource-hash
This Vite plugin replaces content_hash in public resources with actual hashes.
installation
npm install @jswork/vite-public-resource-hash
usage
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import vitePubliResourceHash from '@jswork/vite-public-resource-hash';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), vitePubliResourceHash()],
server: {
host: '0.0.0.0'
}
});
src/app.tsx
<figure>
<img src="/vite.svg?hash=__content_hash__" alt="Vite Logo" className="logo" />
<figcaption>Image from public directory</figcaption>
</figure>
dist/assets/vite.svg?hash=`content_hash``
<figure>
<img src="/vite.svg?hash=8e3a10e1" alt="Vite Logo" class="logo">
<figcaption>Image from public directory</figcaption>
</figure>
license
Code released under the MIT license.