Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manganis: Preserve Folder Files By Default #3293

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

DogeDark
Copy link
Member

@DogeDark DogeDark commented Dec 5, 2024

Adds a optimize_files option for FolderAsset e.g.

const FOLDER_OPTIONS: FolderAssetOptions = FolderAssetOptions::new().with_optimize_files(true);

If the flag is set, the file will go under minor processing. The flag defaults to false.

@DogeDark DogeDark added enhancement New feature or request cli Related to the dioxus-cli program manganis Related to the manganis crate labels Dec 5, 2024
@DogeDark DogeDark marked this pull request as ready for review December 5, 2024 05:11
@jkelleyrtp
Copy link
Member

jkelleyrtp commented Dec 5, 2024

I think we originally wanted Folders to retain their asset names internally but have a different name externally - did that change? I'm ambivalent to either so @ealmloff can make the final call

It seems that the extra processing of the folder contents was a mistake / bad default, seems like we want to preserve contents by default and make optimization opt-in

@DogeDark DogeDark changed the title Feat: preserve_files option for FolderAsset Manganis: Preserve Folder Files By Default Dec 5, 2024
@ealmloff
Copy link
Member

ealmloff commented Dec 5, 2024

What is the advantage of different default optimizations for folders vs files? I would expect these two to point to the same asset:

const FOLDER: ASSET = asset!("/myfolder");
const ASSET: ASSET = asset!("/myfolder/asset.js");

rsx! {
   script { src: "{FOLDER}/asset.js" }
   script { src: ASSET }
}

If asset optimization is breaking some files, we could make it opt in instead of opt out, or just fix the broken optimizations. Either way, I think we should be consistent about the default options regardless of how you import the asset

@DogeDark
Copy link
Member Author

DogeDark commented Dec 14, 2024

I'm mixed between both approaches as one could say that the FolderAsset is for importing something as-is, but I think file preservation should be opt-in for consistency.

@nicoburns
Copy link
Contributor

IMO asset-optimization ought to be opt-in in general. People wanted asset optimization will likely go looking for a setting and find it easily enough. People not wanting optimization are more likely to be surprised by it happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the dioxus-cli program enhancement New feature or request manganis Related to the manganis crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants