From 4faf943ea00be7ef85f5a6421f91b91da60e6d71 Mon Sep 17 00:00:00 2001 From: Kuriko Moe Date: Sun, 1 Mar 2020 17:26:27 +0800 Subject: [PATCH] Fix(pkg output): Fix the pkg output path Fix the problem when outDir is a relative path, wasm-pack will use Cargo.toml as root path, but this._makeEmpty will use package.json --- plugin.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin.js b/plugin.js index 22fe486..0016b68 100644 --- a/plugin.js +++ b/plugin.js @@ -26,6 +26,11 @@ class WasmPackPlugin { this.forceMode = options.forceMode; this.extraArgs = (options.extraArgs || '').trim().split(' ').filter(x => x); this.outDir = options.outDir || "pkg"; + if(!path.isAbsolute(this.outDir)) { + // Fix the problem that the wasm-pack treat the Cargo.toml as the root dir + this.outDir = path.resolve(process.cwd(), this.outDir) + } + this.outName = options.outName || "index"; this.watchDirectories = (options.watchDirectories || []) .concat(path.resolve(this.crateDirectory, 'src'));