7 个版本
0.3.0-alpha.1 | 2024 年 8 月 7 日 |
---|---|
0.3.0-alpha.0 | 2024 年 7 月 31 日 |
0.2.2 | 2024 年 3 月 25 日 |
0.1.1 | 2024 年 2 月 22 日 |
#204 in 数据结构
3,435 每月下载量
用于 dioxus-chessboard
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