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

Fix for #10 Support for JS snippets #67

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,23 +288,13 @@ impl Dist {
.generate_output()
.context("could not generate Wasm bindgen file")?;

let wasm_js = output.js().to_owned();
let wasm_bin = output.wasm_mut().emit_wasm();

let wasm_js_path = dist_dir_path.join(&app_name).with_extension("js");
let wasm_bin_path = dist_dir_path.join(&app_name).with_extension("wasm");

if dist_dir_path.exists() {
log::trace!("Removing already existing dist directory");
fs::remove_dir_all(&dist_dir_path)?;
}

log::trace!("Creating new dist directory");
fs::create_dir_all(&dist_dir_path).context("cannot create build directory")?;

log::trace!("Writing Wasm output into dist directory");
fs::write(&wasm_js_path, wasm_js).context("cannot write js file")?;
fs::write(&wasm_bin_path, wasm_bin).context("cannot write Wasm file")?;
log::trace!("Writing outputs to dist directory");
output.emit(&dist_dir_path)?;

if let Some(static_dir) = self.static_dir_path {
#[cfg(feature = "sass")]
Expand All @@ -329,8 +319,6 @@ impl Dist {

Ok(DistResult {
dist_dir: dist_dir_path,
js: wasm_js_path,
wasm: wasm_bin_path,
})
cecton marked this conversation as resolved.
Show resolved Hide resolved
}
}
Expand Down Expand Up @@ -421,10 +409,6 @@ fn sass(
pub struct DistResult {
/// Directory containing the generated artifacts.
pub dist_dir: PathBuf,
/// JS output generated by wasm-bindgen.
pub js: PathBuf,
/// Wasm output generated by wasm-bindgen.
pub wasm: PathBuf,
}

/// Get the default dist directory.
Expand Down