An esbuild plugin that imports HTML files as minified raw text strings at build time, using html-minifier-terser for minification. Version 0.1.2 is the current stable release, with infrequent updates. It differentiates itself from raw-text loaders by combining import and minification in one plugin, eliminating the need for a separate minification step. Ships TypeScript types and supports customizable minifier options like collapseWhitespace.
npm install esbuild-plugin-minify-htmlNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Build script using esbuild with minifyHTML plugin to import and minify HTML files as raw text.
Always append ?raw to HTML import paths: import content from './file.html?raw'
Add a .d.ts file with: declare module '*.html?raw' { const src: string; export default src; }Migrate to new package: npm install esbuild-plugin-minify-html and update imports
Refer to html-minifier-terser documentation and test minified output for correctness
Add minifyHTML plugin to esbuild.plugins array and ensure import path ends with ?raw.
Place a .d.ts file in your project root with: declare module '*.html?raw' { const src: string; export default src; }Run: npm install html-minifier-terser