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

Feature Request: #[exclude = "example/some_big_directory"] #96

Closed
NfNitLoop opened this issue Jan 20, 2020 · 6 comments
Closed

Feature Request: #[exclude = "example/some_big_directory"] #96

NfNitLoop opened this issue Jan 20, 2020 · 6 comments

Comments

@NfNitLoop
Copy link
Contributor

I was just about to open a bug about how slow rust-embed was performing in release mode...

... then I found that I was accidentally embedding a 70Mb+ node_modules directory. Oops. (Still, it did seem rather slow for a mere 70MB but maybe that's because it's a lot of small files?)

It would be nice if I could embed some directory, but exclude some large subdirectories from that embed. Ex:

#[derive(RustEmbed)]
#[folder = "examples/"]
#[exclude = "examples/big_dir"]

Or, you could make it respect .gitignores? I already had that node_modules directory ignored, which is part of the reason I'd forgotten about it.

Otherwise, thanks for a great crate!

@pyrossh
Copy link
Owner

pyrossh commented Jan 21, 2020

@NfNitLoop I'm glad rust-embed is useful to you. Yes the exclude folder would be needed in this case. Ignoring folders in .gitignore might be harder to implement for now.
Anyone else here has any thoughts/ideas on how this should be done?

#[derive(RustEmbed)]
#[folder = "examples/", exclude = "big_dir"]

@paolobarbolini
Copy link
Contributor

I think having the ability to exclude multiple folders would be enough for the moment. Having rust-embed follow .gitignore would probably cause more harm than good, since most projects git ignore the output of module bundlers like webpack but need those folders for the Rust code to work.

@AzureMarker
Copy link
Collaborator

In order to exclude multiple folders, it may need to look like this:

#[derive(RustEmbed)]
#[folder = "examples/", exclude("big_dir1", "big_dir2")]

@Boscop
Copy link

Boscop commented Jan 21, 2020

If excluding folders gets allowed, what about individual (big) files, and what about globs? 🤔
Also, it would make sense to also use the shell-expand feature on the exclusion paths.

@qrnch-jan
Copy link

I'm looking for something that's mostly similar, but I have need for something more granular. Basically there are two issues for us:

  1. We have a master repo with several Rocket projects in it. These Rocket projects use a shared "htstatic" directory in the tree which contains img, css and js with their respective files. Some files within are used by all Rocket applications, some are not. Currently rust-embed will add all files to all Rocket projects, unless we split the htstatic directory up, which we really don't want to do.
  2. For debug builds we have our foo.js and our foo.css with all its bells and whistles, but for the release builds we want to use "minified" versions of them. Our build system builds these into foo.min.js and foo.min.css, and in the final binary we want to include the ".min." versions, but not the originals.

In our case it would be really useful if:
The debug build just publishes everything, as it currently does.
But for the release build there should be a way to either exclude some entries or to explicitly state what should be included. In our case we'd prefer to have something like:

#[folder = "../../libs/htstatic/", include_manifest = "release_files"]

.. and release_files would be a file of file/directory entries that should be included in the list for release builds.

The upside of being able to specify an external manifest file, rather than adding the entries to the source code, is that build systems can generate these lists as appropriate for the platform it is building on.

Also, I'd like to voice some concerns about using .gitignore as an exclude list: Not everyone uses git, and not all projects live in the root of a repository. Please pick a name which is agnotic to the source management system.

@pyrossh
Copy link
Owner

pyrossh commented Aug 31, 2021

This is implemented and released in v6.1.0. Thanks to @mbme.

@pyrossh pyrossh closed this as completed Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants