1.0.1 • Published 9 months ago

vite-public-resource-hash v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

vite-public-resource-hash

This Vite plugin replaces content_hash in public resources with actual hashes.

version license size download

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.

1.0.1

9 months ago