Restore manganis optimizations (#3195)
* Create a crate for constant serialization of config structs for manganis * use SerializeConst for the image asset builder * switch to a declarative macro for assets * add serializable options for each asset type * implement the new manganis macro * optimize assets in the CLI * Fix assets with dioxus formattable * reduce fuzzing test limits * use the new syntax in examples * fix avif support * Fix manganis doc tests * cache asset optimization * Split out asset and bundled asset * make hash pointer width independent * Fix manganis macro docs * add constvec::is_empty method to fix clippy lint * remove nasm feature * simplify test_rsplit_once test so typos passes * revert example change from clippy fix * always accept unix paths * fix windows path seperator * fix folder asset hash * Optimize assets in a blocking task * Fix asset options docs * Document Asset and BundledAsset * simplify the linker macro a bit * add more docs to AssetParser expansion * add image format helpers * Split by both unix and windows path separators and take the smallest one
This commit is contained in:
1 parent
31d72db82d
commit
f9617c8d33
64 files changed
+6233
-704
No files matched your search
@@ -0,0 +1,31 @@
|
||||
# Manganis
|
||||
|
||||
The Manganis allows you to submit assets to any build tool that supports collecting assets. It makes it easy to self-host assets that are distributed throughout your libraries. Manganis also handles optimizing, converting, and fetching assets.
|
||||
|
||||
If you defined this in a component library:
|
||||
|
||||
```rust
|
||||
use manganis::{Asset, asset};
|
||||
const AVIF_ASSET: Asset = manganis::asset!("/assets/image.png");
|
||||
```
|
||||
|
||||
AVIF_ASSET will be set to a new file name that will be served by some CLI. That file can be collected by any package that depends on the component library.
|
||||
|
||||
```rust
|
||||
use manganis::{ImageFormat, ImageAssetOptions, Asset, asset, ImageSize};
|
||||
// You can collect arbitrary files. Absolute paths are resolved relative to the package root
|
||||
const _: Asset = asset!("/assets/script.js");
|
||||
|
||||
// You can collect images which will be automatically optimized
|
||||
pub const PNG_ASSET: Asset =
|
||||
asset!("/assets/image.png");
|
||||
// Resize the image at compile time to make the assets smaller
|
||||
pub const RESIZED_PNG_ASSET: Asset =
|
||||
asset!("/assets/image.png", ImageAssetOptions::new().with_size(ImageSize::Manual { width: 52, height: 52 }));
|
||||
// Or convert the image at compile time to a web friendly format
|
||||
pub const AVIF_ASSET: Asset = asset!("/assets/image.png", ImageAssetOptions::new().with_format(ImageFormat::Avif));
|
||||
```
|
||||
|
||||
## Adding Support to Your CLI
|
||||
|
||||
To add support for your CLI, you need to integrate with the [manganis_cli_support](https://github.com/DioxusLabs/manganis/tree/main/cli-support) crate. This crate provides utilities to collect assets that integrate with the Manganis macro. It makes it easy to integrate an asset collection and optimization system into a build tool.
|
||||
Reference in new issue
Block a user