Allow CDN_PKG_PATH at runtime as well as current build time, preferring it when available. (#2466)

This commit is contained in:
zakstucke 2024-03-28 10:30:54 +02:00 committed by GitHub
parent 73b8c7872e
commit fd2817de26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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