7 个版本

0.3.0-alpha.12024 年 8 月 7 日
0.3.0-alpha.02024 年 7 月 31 日
0.2.2 2024 年 3 月 25 日
0.1.1 2024 年 2 月 22 日

#204 in 数据结构

Download history 891/week @ 2024-05-01 602/week @ 2024-05-08 598/week @ 2024-05-15 509/week @ 2024-05-22 393/week @ 2024-05-29 500/week @ 2024-06-05 793/week @ 2024-06-12 633/week @ 2024-06-19 430/week @ 2024-06-26 428/week @ 2024-07-03 388/week @ 2024-07-10 724/week @ 2024-07-17 342/week @ 2024-07-24 859/week @ 2024-07-31 1276/week @ 2024-08-07 813/week @ 2024-08-14

3,435 每月下载量
用于 dioxus-chessboard

MIT/Apache 和可能 GPL-3.0-or-later

22KB
199

Manganis

Manganis 允许您将资产提交到支持资产收集的构建工具。它使得在您的库中分布式部署的资产的自托管变得容易。Manganis 还负责优化、转换和获取资产。

如果在组件库中定义此内容

const AVIF_ASSET: &str = manganis::mg!("rustacean-flat-gesture.png");

AVIF_ASSET 将被设置为一些 CLI 将提供的新文件名。该文件可以被任何依赖于组件库的包收集。

// You can include tailwind classes that will be collected into the final binary
const TAILWIND_CLASSES: &str = manganis::classes!("flex flex-col p-5");

// You can also collect arbitrary files. Relative paths are resolved relative to the package root
const _: &str = manganis::mg!("test-package-dependency/src/asset.txt"); 
// You can use URLs to copy read the asset at build time
const _: &str = manganis::mg!("https://rustacean.net/assets/rustacean-flat-happy.png");

// You can collect images which will be automatically optimized
pub const PNG_ASSET: manganis::ImageAsset =
    manganis::mg!(image("rustacean-flat-gesture.png"));
// Resize the image at compile time to make the assets smaller
pub const RESIZED_PNG_ASSET: manganis::ImageAsset =
    manganis::mg!(image("rustacean-flat-gesture.png").size(52, 52));
// Or convert the image at compile time to a web friendly format
pub const AVIF_ASSET: manganis::ImageAsset = manganis::mg!(image("rustacean-flat-gesture.png")
    .format(ImageType::Avif));
// You can even include a low quality preview of the image embedded into the url
pub const AVIF_ASSET_LOW: manganis::ImageAsset = manganis::mg!(image("rustacean-flat-gesture.png")
	.format(ImageType::Avif)
	.low_quality_preview());

// You can also collect google fonts
pub const ROBOTO_FONT: &str = manganis::mg!(font()
    .families(["Roboto"]));
// Specify weights for fonts to collect
pub const COMFORTAA_FONT: &str = manganis::mg!(font()
    .families(["Comfortaa"])
    .weights([400]));
// Or specific text to include only the characters used in that text
pub const ROBOTO_FONT_LIGHT_FONT: &str = manganis::mg!(font()
    .families(["Roboto"])
    .weights([200])
    .text("hello world"));

在您的 CLI 中添加支持

要添加对您的 CLI 的支持,您需要集成 manganis_cli_support crate。这个 crate 提供了与 Manganis 宏集成的实用工具,以便于将资产收集和优化系统集成到构建工具中。

依赖关系

~0–20MB
~283K SLoC