Skip to content

Commit

Permalink
feat: use cdn url for static assets (#2281)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomiti committed Feb 9, 2024
1 parent d4bdc36 commit ace1486
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions integrations/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub fn html_parts_separated(
options: &LeptosOptions,
meta: Option<&MetaContext>,
) -> (String, &'static str) {
let pkg_path = &options.site_pkg_dir;
let pkg_path = option_env!("CDN_PKG_PATH").map(String::from).unwrap_or(format!("/{}", options.site_pkg_dir));
let output_name = &options.output_name;
let nonce = use_nonce();
let nonce = nonce
Expand Down Expand Up @@ -107,8 +107,8 @@ pub fn html_parts_separated(
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
{head}
<link rel="modulepreload" href="/{pkg_path}/{output_name}.js"{nonce}>
<link rel="preload" href="/{pkg_path}/{wasm_output_name}.wasm" as="fetch" type="application/wasm" crossorigin=""{nonce}>
<link rel="modulepreload" href="{pkg_path}/{output_name}.js"{nonce}>
<link rel="preload" href="{pkg_path}/{wasm_output_name}.wasm" as="fetch" type="application/wasm" crossorigin=""{nonce}>
<script type="module"{nonce}>
function idle(c) {{
if ("requestIdleCallback" in window) {{
Expand All @@ -118,9 +118,9 @@ pub fn html_parts_separated(
}}
}}
idle(() => {{
import('/{pkg_path}/{output_name}.js')
import('{pkg_path}/{output_name}.js')
.then(mod => {{
mod.default('/{pkg_path}/{wasm_output_name}.wasm').then({import_callback});
mod.default('{pkg_path}/{wasm_output_name}.wasm').then({import_callback});
}})
}});
</script>
Expand Down

0 comments on commit ace1486

Please sign in to comment.