From ddfb21c4530704907a07f18336415443d15cfad2 Mon Sep 17 00:00:00 2001 From: rimutaka Date: Fri, 10 Jan 2025 17:01:21 +1300 Subject: [PATCH 1/2] docs: Added rel path to `--out-dir` example --- docs/src/commands/build.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/src/commands/build.md b/docs/src/commands/build.md index 9b12922e5..e13254347 100644 --- a/docs/src/commands/build.md +++ b/docs/src/commands/build.md @@ -22,15 +22,18 @@ path is given, the `build` command will run in the current directory. ## Output Directory -By default, `wasm-pack` will generate a directory for its build output called `pkg`. -If you'd like to customize this you can use the `--out-dir` flag. +By default, `wasm-pack` generates a directory for its build output called `pkg` +in the same directory as the `Cargo.toml` file. +Use the `--out-dir` flag to place the build output in a different location. ``` -wasm-pack build --out-dir out +wasm-pack build examples/js-hello-world --out-dir ../builds/js-hello-world ``` -The above command will put your build artifacts in a directory called `out`, instead -of the default `pkg`. +The above command will create directory `examples/builds/js-hello-world` +and place the build artifacts there, instead of the default `examples/js-hello-world/pkg`. + +The `--out-dir` path can be absolute or relative to the directory that contains the `Cargo.toml` file. ## Generated file names From 3da9f3f9403e61640bf95e25d975730dc35b4d1e Mon Sep 17 00:00:00 2001 From: rimutaka Date: Fri, 10 Jan 2025 22:00:27 +1300 Subject: [PATCH 2/2] docs: Added 2 more `--out-dir` examples --- docs/src/commands/build.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/src/commands/build.md b/docs/src/commands/build.md index e13254347..8c22d81d5 100644 --- a/docs/src/commands/build.md +++ b/docs/src/commands/build.md @@ -26,12 +26,12 @@ By default, `wasm-pack` generates a directory for its build output called `pkg` in the same directory as the `Cargo.toml` file. Use the `--out-dir` flag to place the build output in a different location. -``` -wasm-pack build examples/js-hello-world --out-dir ../builds/js-hello-world -``` +Examples with and without the `--out-dir` flag: -The above command will create directory `examples/builds/js-hello-world` -and place the build artifacts there, instead of the default `examples/js-hello-world/pkg`. +- `wasm-pack build` - creates `pkg` directory next to `Cargo.toml` file +- `wasm-pack build --out-dir out` - creates `out` directory next to `Cargo.toml` file +- `wasm-pack build examples/js-hello-world --out-dir ../builds/js-hello-world` - +creates `examples/builds/js-hello-world` The `--out-dir` path can be absolute or relative to the directory that contains the `Cargo.toml` file.