Minify css template literals in production build

Author: timolinsCreated Aug 10, 2022Updated Jun 29, 2026
Labelsenhancementhelp wanted

Problem

Most of the css is written within template literals, which is not minified in the build step at the moment. This adds a lot of unnecessary whitespace and bytes, which can be reduced by improving minification at build time.

Screenshot of sub-optimal built output: Screenshot of unminified parts in source

Goals

  • Remove whitespace from tagged string literals
  • Minify CSS properly (width: 0px;width:0;)
  • Source Maps should still work

Research

react-hot-toast is using tsup for building, which uses esbuild internally .

Resources I found while experimenting, with little success:

Any help would be appreciated

Source: timolins/react-hot-toast