{"id":25346,"library":"esbuild-plugin-html-minifier-terser","title":"esbuild HTML Minifier Plugin","description":"An esbuild plugin that minifies HTML output files using html-minifier-terser. Version 1.0.0 is current. It processes HTML files after other plugins (e.g., @craftamap/esbuild-plugin-html) have generated them. Key differentiators: integrates with esbuild's build process, supports glob patterns for file selection, and allows custom minifier options. No active development observed since release.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/Level222/esbuild-plugin-html-minifier-terser","tags":["javascript","esbuild","plugin","html-minifier-terser","html","minifier","minify","terser","typescript"],"install":[{"cmd":"npm install esbuild-plugin-html-minifier-terser","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-html-minifier-terser","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-html-minifier-terser","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency - plugin requires esbuild to work","package":"esbuild","optional":true},{"reason":"peer dependency - core minification library","package":"html-minifier-terser","optional":false}],"imports":[{"note":"Package is ESM-only. CommonJS require may fail depending on Node version.","wrong":"const htmlMinifierPlugin = require('esbuild-plugin-html-minifier-terser')","symbol":"default","correct":"import htmlMinifierPlugin from 'esbuild-plugin-html-minifier-terser'"},{"note":"No named exports. Only default export exists.","wrong":"import { minifyHtml } from 'esbuild-plugin-html-minifier-terser'","symbol":"minifyHtml","correct":"// Not exported. Use default import for plugin."},{"note":"TypeScript users should import the Options type from html-minifier-terser directly.","wrong":"import { Options } from 'esbuild-plugin-html-minifier-terser'","symbol":"Options","correct":"import type { Options } from 'html-minifier-terser'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport htmlMinifierPlugin from 'esbuild-plugin-html-minifier-terser';\n\nawait esbuild.build({\n  entryPoints: ['src/index.js'],\n  outdir: 'dist',\n  bundle: true,\n  plugins: [\n    htmlMinifierPlugin({\n      include: '**/*.html',\n      baseDir: 'outdir',\n      minifierOptions: {\n        caseSensitive: true,\n        collapseWhitespace: true,\n        keepClosingSlash: true,\n        minifyCSS: true,\n        minifyJS: true,\n        removeComments: true,\n      },\n    }),\n  ],\n});","lang":"typescript","description":"Minifies all HTML files in the output directory during esbuild build."},"warnings":[{"fix":"Include all desired options in minifierOptions, as defaults are not applied.","message":"minifierOptions are not merged with defaults; providing an object overwrites all defaults.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure plugins that generate HTML are placed before htmlMinifierPlugin in the plugins array.","message":"Plugin runs in the 'onEnd' hook, meaning HTML files must be generated by other plugins before minification.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use default import. Do not try to import named symbols.","message":"Only default export is available; no named exports.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Run 'npm i -D html-minifier-terser' in addition to the plugin.","message":"Package depends on html-minifier-terser which must be installed explicitly as a devDependency.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install html-minifier-terser as a devDependency: npm i -D html-minifier-terser","cause":"html-minifier-terser is a peer dependency not automatically installed.","error":"Error: esbuild-plugin-html-minifier-terser requires a peer of html-minifier-terser but none is installed."},{"fix":"Use import syntax or set 'type': 'module' in package.json.","cause":"Using require() in a CommonJS context where package is ESM-only.","error":"TypeError: htmlMinifierPlugin is not a function (or TypeError: (0 , ...) is not a function)"},{"fix":"Place htmlMinifierPlugin after plugins that generate HTML files.","cause":"Order of plugins in array matters; HTML files not yet generated when plugin runs.","error":"Error: Plugin 'html-minifier-terser' must be used after HTML output plugins."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}