diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 5f1d8f53..90125178 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -3,7 +3,7 @@ on: [push, pull_request]
jobs:
lint:
- name: build
+ name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b38dd3ab..35c3e52d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,12 +3,20 @@ changelog
This changelog follows the patterns described here: https://keepachangelog.com/en/1.0.0/.
## Unreleased
+
+## 0.4.0
### added
- Added support for layered configuration via `Trunk.toml` & environment variables.
- Added an example `Trunk.toml` to the root of the repository showing all possible config values along with their defaults.
+
+### changed
- README has been updated with details on how the config system works.
- Removed a fair amount of code duplication as part of the configuration feature.
-- Trunk now exits with a non-zero code when an error takes place during execution.
+- Added full release automation with optimized release binaries for Linux, MacOS & Windows (all x64).
+
+### fixed
+- Closed [#37](https://github.com/thedodd/trunk/issues/37): Trunk now exits with a non-zero code when an error takes place during execution.
+- Closed [#40](https://github.com/thedodd/trunk/issues/40): Trunk is now copying JS snippets from wasm-bindgen into the dist dir as part of the standard build/watch/serve commands.
## 0.3.1
### fixed
diff --git a/Cargo.lock b/Cargo.lock
index 65a04f35..1ac2d5e8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -96,7 +96,7 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -151,7 +151,7 @@ dependencies = [
"polling 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"socket2 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"vec-arena 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "wepoll-sys-stjepang 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "wepoll-sys-stjepang 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -172,7 +172,7 @@ dependencies = [
"socket2 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"vec-arena 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"waker-fn 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "wepoll-sys-stjepang 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "wepoll-sys-stjepang 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -272,7 +272,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -553,7 +553,7 @@ dependencies = [
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -562,7 +562,7 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -577,7 +577,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -664,6 +664,11 @@ dependencies = [
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "fs_extra"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
[[package]]
name = "fsevent"
version = "0.4.0"
@@ -783,7 +788,7 @@ dependencies = [
"proc-macro-hack 0.5.18 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -923,7 +928,7 @@ dependencies = [
"markup5ever 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1310,7 +1315,7 @@ dependencies = [
"proc-macro-hack 0.5.18 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1336,7 +1341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1362,7 +1367,7 @@ dependencies = [
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.77 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "wepoll-sys-stjepang 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "wepoll-sys-stjepang 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1393,7 +1398,7 @@ dependencies = [
"proc-macro-error-attr 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
"version_check 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1619,7 +1624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1759,7 +1764,7 @@ dependencies = [
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1774,7 +1779,7 @@ dependencies = [
"serde_derive 1.0.116 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.57 (registry+https://github.com/rust-lang/crates.io-index)",
"sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1829,7 +1834,7 @@ dependencies = [
"proc-macro-error 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1839,7 +1844,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "syn"
-version = "1.0.40"
+version = "1.0.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1949,7 +1954,7 @@ dependencies = [
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
"standback 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1975,6 +1980,7 @@ dependencies = [
"cargo_metadata 0.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
"console 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"envy 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "fs_extra 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"indicatif 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"nipper 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2110,7 +2116,7 @@ dependencies = [
"log 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2141,7 +2147,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro2 1.0.21 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-backend 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
"wasm-bindgen-shared 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2162,7 +2168,7 @@ dependencies = [
[[package]]
name = "wepoll-sys-stjepang"
-version = "1.0.6"
+version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cc 1.0.59 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2286,6 +2292,7 @@ dependencies = [
"checksum fastrand 1.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "5c85295147490b8fcf2ea3d104080a105a8b2c63f9c319e82c02d8e952388919"
"checksum femme 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2af1a24f391a5a94d756db5092c6576aad494b88a71a5a36b20c67b63e0df034"
"checksum filetime 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "3ed85775dcc68644b5c950ac06a2b23768d3bc9390464151aaf27136998dcf9e"
+"checksum fs_extra 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2022715d62ab30faffd124d40b76f4134a550a87792276512b18d63272333394"
"checksum fsevent 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ab7d1bd1bd33cc98b0889831b72da23c0aa4df9cec7e0702f46ecea04b35db6"
"checksum fsevent-sys 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f41b048a94555da0f42f1d632e2e19510084fb8e303b0daa2816e733fb3644a0"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
@@ -2425,7 +2432,7 @@ dependencies = [
"checksum structopt 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "6cc388d94ffabf39b5ed5fadddc40147cb21e605f53db6f8f36a625d27489ac5"
"checksum structopt-derive 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5e2513111825077552a6751dfad9e11ce0fba07d7276a3943a037d7e93e64c5f"
"checksum subtle 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd"
-"checksum syn 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "963f7d3cc59b59b9325165add223142bbf1df27655d07789f109896d353d8350"
+"checksum syn 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "6690e3e9f692504b941dc6c3b188fd28df054f7fb8469ab40680df52fdcc842b"
"checksum tendril 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "707feda9f2582d5d680d733e38755547a3e8fb471e7ba11452ecfd9ce93a5d3b"
"checksum terminal_size 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "9a14cd9f8c72704232f0bfc8455c0e861f0ad4eb60cc9ec8a170e231414c1e13"
"checksum termios 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6f0fcee7b24a25675de40d5bb4de6e41b0df07bc9856295e7e2b3a3600c400c2"
@@ -2461,7 +2468,7 @@ dependencies = [
"checksum wasm-bindgen-macro-support 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)" = "f249f06ef7ee334cc3b8ff031bfc11ec99d00f34d86da7498396dc1e3b1498fe"
"checksum wasm-bindgen-shared 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)" = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
"checksum web-sys 0.3.45 (registry+https://github.com/rust-lang/crates.io-index)" = "4bf6ef87ad7ae8008e15a355ce696bed26012b7caa21605188cfd8214ab51e2d"
-"checksum wepoll-sys-stjepang 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6fd319e971980166b53e17b1026812ad66c6b54063be879eb182342b55284694"
+"checksum wepoll-sys-stjepang 1.0.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1fdfbb03f290ca0b27922e8d48a0997b4ceea12df33269b9f75e713311eb178d"
"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
"checksum winapi 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
diff --git a/Cargo.toml b/Cargo.toml
index 7d89a2d2..5ea3c677 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,6 +17,7 @@ async-std = { version="1.6.3", features=["attributes", "unstable"] }
cargo_metadata = "0.11.1"
console = "0.12.0"
envy = "0.4.1"
+fs_extra = "1.2.0"
futures = "0.3.5"
indicatif = "0.15.0"
nipper = "0.1.8"
diff --git a/README.md b/README.md
index 57c7ffab..f04bb507 100644
--- a/README.md
+++ b/README.md
@@ -70,15 +70,15 @@ The contents of your `dist` dir are now ready to be served on the web. But that'
## commands
### build
-`trunk build [index.html]` runs a cargo build targeting the wasm32 instruction set, runs `wasm-bindgen` on the built WASM, spawns asset build pipelines for any assets defined in the target `index.html`.
+`trunk build` runs a cargo build targeting the wasm32 instruction set, runs `wasm-bindgen` on the built WASM, and spawns asset build pipelines for any assets defined in the target `index.html`.
-Trunk leverages Rust's powerful concurrency primitives for maximum build speeds.
+Trunk leverages Rust's powerful concurrency primitives for maximum build speeds & throughput.
### watch
-`trunk watch [index.html]` does the same thing as `trunk build`, but watches the filesystem for changes, triggering new builds as changes are detected.
+`trunk watch` does the same thing as `trunk build`, but also watches the filesystem for changes, triggering new builds as changes are detected.
### serve
-`trunk serve [index.html]` does the same thing as `trunk watch`, but also spawns a web server.
+`trunk serve` does the same thing as `trunk watch`, but also spawns a web server.
### clean
`trunk clean` cleans up any build artifacts generated from earlier builds.
@@ -91,6 +91,7 @@ Currently supported assets:
- ✅ `css`: Trunk will copy linked css files found in the source HTML without content modification. This content is hashed for cache control.
- In the future, Trunk will resolve local `@imports`, will handle minification (see [trunk#7](https://github.com/thedodd/trunk/issues/3)), and we may even look into a pattern where any CSS found in the source tree will be bundled, which would enable a nice zero-config "component styles" pattern. See [trunk#3](https://github.com/thedodd/trunk/issues/3) for more details.
- ✅ `icon`: Trunk will automatically copy referenced icons to the `dist` dir. This content is hashed for cache control.
+- ✅ `js snippets`: [wasm-bindgen JS snippets](https://rustwasm.github.io/docs/wasm-bindgen/reference/js-snippets.html) are automatically copied to the dist dir, hashed and ready to rock.
### images & other resources
Images and other resource types can be copied into the `dist` dir by adding a link like this to your source HTML: `` (note the `rel="trunk-dist"` attribute). This will cause Trunk to find the target resource, and copy it to the `dist` dir unmodified. No hashing will be applied. The link itself will be removed from the HTML.
diff --git a/src/build.rs b/src/build.rs
index 30530155..dd4ca2e5 100644
--- a/src/build.rs
+++ b/src/build.rs
@@ -4,10 +4,10 @@ use std::ffi::OsString;
use std::path::PathBuf;
use std::sync::Arc;
-use anyhow::{anyhow, bail, ensure, Result};
+use anyhow::{anyhow, bail, ensure, Context, Result};
use async_process::{Command, Stdio};
-use async_std::fs;
use async_std::task::{spawn, spawn_blocking, JoinHandle};
+use async_std::{fs, path};
use cargo_metadata::{Metadata, MetadataCommand, Package};
use console::Emoji;
use futures::stream::{FuturesUnordered, StreamExt};
@@ -18,6 +18,7 @@ use crate::config::RtcBuild;
const TRUNK_ID: &str = "__trunk-id";
const HREF_ATTR: &str = "href";
+const SNIPPETS_DIR: &str = "snippets";
/// A system used for building a Rust WASM app & bundling its assets.
///
@@ -211,6 +212,7 @@ impl BuildSystem {
/// Spawn the wasm-bindgen build process.
fn spawn_wasm_bindgen_build(&self, file_name: String) -> JoinHandle> {
let (dist, bindgen_out, app_target_wasm) = (self.cfg.dist.clone(), self.bindgen_out.clone(), self.app_target_wasm.clone());
+ let (snippets_dir_from, snippets_dir_to) = (self.bindgen_out.join(SNIPPETS_DIR), self.cfg.dist.join(SNIPPETS_DIR));
self.progress.set_message(&format!("{}starting wasm-bindgen build", Emoji("📦 ", "")));
spawn(async move {
@@ -228,6 +230,7 @@ impl BuildSystem {
.map_err(|err| anyhow!("error spawning wasm-bindgen build: {}", err))?
.output()
.await;
+
// Handle build results.
match build_result {
Ok(output) => {
@@ -237,6 +240,7 @@ impl BuildSystem {
}
Err(err) => return Err(anyhow!("error during wasm-bindgen build: {}", err)),
}
+
// Copy the generated WASM & JS loader to the dist dir, and generate the needed body
// for the output HTML.
let hashed_js_name = format!("{}.js", &file_name);
@@ -248,6 +252,11 @@ impl BuildSystem {
fs::copy(js_loader_path, js_loader_path_dist).await?;
fs::copy(wasm_path, wasm_path_dist).await?;
+ // Check for any snippets, and copy them over.
+ Self::copy_dir_recursive(snippets_dir_from, snippets_dir_to)
+ .await
+ .with_context(|| "error copying snippets dir")?;
+
Ok(WasmBindgenOutput {
js_output: hashed_js_name,
wasm_output: hashed_wasm_name,
@@ -255,6 +264,23 @@ impl BuildSystem {
})
}
+ /// A utility function to recursively copy a directory.
+ async fn copy_dir_recursive(from_dir: PathBuf, to_dir: PathBuf) -> Result<()> {
+ if !path::PathBuf::from(&from_dir).exists().await {
+ return Ok(());
+ }
+ spawn_blocking(move || {
+ let opts = fs_extra::dir::CopyOptions {
+ overwrite: true,
+ content_only: true,
+ ..Default::default()
+ };
+ Ok(fs_extra::dir::copy(from_dir, to_dir, &opts)?)
+ })
+ .await
+ .map(|_| ())
+ }
+
/// Spawn asset building/bundling pipelines.
///
/// Assets are given an ID which corresponds to an ID added to the DOM. Once the processing