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

Add a macro to serve files from OUT_DIR #3

Closed
BeneSim opened this issue Feb 19, 2024 · 2 comments
Closed

Add a macro to serve files from OUT_DIR #3

BeneSim opened this issue Feb 19, 2024 · 2 comments

Comments

@BeneSim
Copy link

BeneSim commented Feb 19, 2024

Hey,

I really like this crate but I'm facing a problem: I have some static files that get minified and packed using vite / rollup which itself gets called in a build.rs buildscript. One useful environment variable in such a build.rs script is OUT_DIR where I can store the build artifacts of npm build.

I want to include those build artifacts with memory_serve. However, you're just turning the input TokenStream in your proc Macro into a String so macros like env!("OUT_DIR") won't get resolved. In fact, as far as I know resolving TokenStreams is unstable at the moment.

Maybe we can add another macro load_assets_from_out_dir! or something similar. I'm going to preare a PR for that that you might consider.

@marlonbaeten
Copy link
Member

Thank you @BeneSim, and sorry for my late response.

That seems reasonable, but I would prefer not introducing a new macro. Would it be an option for you if I added a MEMORY_SERVE_ROOT environment variable that would have priority over CARGO_MANIFEST_DIR when resolving a relative path? See #5

@marlonbaeten
Copy link
Member

I have released version 0.4.4 - hopefully this solves your issue. If not - please reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants