A plugin for esbuild that minifies template literal strings by collapsing whitespace and removing whitespace around HTML tags. Version 0.13.1 is current; it supports node >=12 and requires esbuild >=0.13.0 <1.0.0 as a peer dependency. Features include source map support, the ability to ignore specific template literals with a comment, and options like `keepComments` (preserve HTML comments) and `taggedOnly` (minify only tagged templates). It ships TypeScript types. Unlike other minifiers, it works as two esbuild plugins that require the `write` option to be `false`, writing output files via a separate `writeFiles()` plugin.
npm install esbuild-minify-templatesVerified import paths — ran on the pinned version, not inferred.
Demonstrates the essential setup: import the two plugins, add them to the esbuild plugins array, and set write to false.
Set esbuild build option 'write' to false.
Add writeFiles() to plugins list after minifyTemplates() and any other output-modifying plugins.
Use import syntax or switch to ES modules in your project.
Set esbuild 'minify' to false and 'legalComments' to 'inline' for the ignore comment to work.
Use import syntax: import { minifyTemplates } from 'esbuild-minify-templates';Use named import: import { writeFiles } from 'esbuild-minify-templates';Set the esbuild build option 'write' to false.