Skip to content

Latest commit

 

History

History
50 lines (38 loc) · 1.33 KB

README.md

File metadata and controls

50 lines (38 loc) · 1.33 KB

Example — React + Vite

A minimal task-list app that gets protected automatically at build time.

Run it

cd examples/react-vite
npm install          # html-guard is linked from the repo root via file:../..
npm run dev          # normal development — protection is build-only
npm run build        # vite build + HTML-Guard runs on dist/
npm run preview      # serve the protected build

After npm run build check dist/:

  • dist/assets/*.js — string pool + minification, no sourcemap refs
  • dist/assets/*.map — deleted
  • dist/index.html — comments stripped, integrity="sha384-…" added
  • the app behaves exactly like the dev build

How the plugin is wired

// vite.config.js
import htmlGuard from 'html-guard/plugins/vite';

export default {
  plugins: [
    react(),
    htmlGuard({
      js: { strings: true, minify: true },
      html: { integrity: true, watermark: true },
      files: { deleteMaps: true }
    })
  ]
};

Prefer a manual pipeline instead of the plugin?

npm run build && npx html-guard protect dist --react

Also works with

  • CRA — react-scripts build && npx html-guard protect build --react
  • Next.js static export — next build && next export && npx html-guard protect out --react
  • Any static output — point protect at the folder with index.html