2 unstable releases
Uses new Rust 2024
| 0.2.0 | Oct 16, 2026 |
|---|---|
| 0.1.0 | Apr 23, 2026 |
#2232 in Procedural macros
110 downloads per month
Used in esp-hal-wifimanager
13KB
259 lines
include-minifier
Like include_str!, but html files are minified at compile time, optionally gzipped.
// &'static str
const PANEL: &str = include_minifier::include_minified!("src/panel.html");
// &'static [u8], serve with `Content-Encoding: gzip`
const PANEL_GZ: &[u8] = include_minifier::include_minified_gzip!("src/panel.html");
Paths are relative to the crate's Cargo.toml, and the file is tracked for rebuilds.
Non-html files are included unchanged (include_minified_gzip! still gzips them).
The minifier is small and conservative, so it builds fast and never changes behaviour:
it removes indentation, blank lines and comments, but leaves <pre>/<textarea>, js strings
and template literals untouched and doesn't rewrite js or css. With gzip on top that's within a
few hundred bytes of a full minifier.
Dependencies
~2MB
~41K SLoC