From 2c06b9659c5bb0dec1d4ea3ce60875bb699797dc Mon Sep 17 00:00:00 2001 From: Zak Stucke Date: Mon, 25 Mar 2024 09:06:50 +0000 Subject: [PATCH] Allow CDN_PKG_PATH at runtime as well as current build time, preferring it when available. --- integrations/utils/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/integrations/utils/src/lib.rs b/integrations/utils/src/lib.rs index 5524d7da6e..fa9b30abcc 100644 --- a/integrations/utils/src/lib.rs +++ b/integrations/utils/src/lib.rs @@ -56,9 +56,16 @@ pub fn html_parts_separated( options: &LeptosOptions, meta: Option<&MetaContext>, ) -> (String, &'static str) { - let pkg_path = option_env!("CDN_PKG_PATH") - .map(Cow::from) - .unwrap_or_else(|| format!("/{}", options.site_pkg_dir).into()); + // First check runtime env, then build time, then default: + let pkg_path = match std::env::var("CDN_PKG_PATH").ok().map(Cow::from) { + Some(path) => path, + None => { + match option_env!("CDN_PKG_PATH").map(Cow::from) { + Some(path) => path, + None => format!("/{}", options.site_pkg_dir).into(), + } + } + }; let output_name = &options.output_name; let nonce = use_nonce(); let nonce = nonce