static-web-minify

Crates.iostatic-web-minify
lib.rsstatic-web-minify
version1.0.0
created_at2025-05-25 10:02:08.784513+00
updated_at2025-05-25 10:02:08.784513+00
descriptionMinimfy css, js, html file as an inline const in your high-performance compiled web application
homepage
repositoryhttps://github.com/emeric-martineau/static-web-minify
max_upload_size
id1688233
size18,027
Emeric MARTINEAU (emeric-martineau)

documentation

README

Static Web Minify for Rust lang 🦀

A minifiy for css, js, html file as an inline const in your high-performance compiled web application. Inspired by const-css-minify.

Unlinke include_str!(), you must put the name file from root of your rust project (see issue 54725).

Dependencies

This project has dependencies to :

Available macros

  • minify_css_str: produce a minified css from string,
  • minify_css_file: produce a minified css from file,
  • minify_js_str: produce a minified js from string,
  • minify_js_file: produce a minified js from file,
  • minify_html_str: produce a minified html from string,
  • minify_html_file: produce a minified html from file,
  • gzip_str: produce a gzip stream from string,
  • gzip_file: produce a gzip stream from file.

Example

use static_web_minify::minify_js_file;

// this is probably the pattern you want to use
const JS: &str = minify_js_file!("tests/test.js");

It's also possible to include a raw string with:

use static_web_minify::minify_js_str;

const JS: &str = minify_js_str!(r#"
    function my_func() {
        // Great !
    }
"#);
assert_eq!(JS, "var my_func=(()=>{})");
Commit count: 1

cargo fmt