Skip to content

Commit

Permalink
Merge pull request #9 from edmellum/base-url-for-wasm
Browse files Browse the repository at this point in the history
Add serving wasm file from other places than root
  • Loading branch information
Justin Wernick committed Apr 8, 2021
2 parents 722e706 + 822c895 commit 94d7568
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,14 @@ fn bundle_index_html(opt: &WebBundlerOpt) -> Result<()> {
package_js_path.display()
)
})?;

let wasm_path = std::path::Path::new(opt.base_url.as_ref().unwrap_or(&"".to_string()))
.join(format!("app-{}.wasm", opt.wasm_version));

let javascript = format!(
r#"<script type="module">{} init('app-{}.wasm'); </script>"#,
package_js_content, opt.wasm_version
r#"<script type="module">{} init('{}'); </script>"#,
package_js_content,
wasm_path.display()
);
tera_context.insert("javascript", &javascript);

Expand Down

0 comments on commit 94d7568

Please sign in to comment.