vite-plugin-wasm-pack
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -13,2 +13,4 @@ "use strict"; | ||
const pkg = 'pkg'; | ||
let config_base; | ||
let config_assetsDir; | ||
const cratePaths = narrowing_1.isString(crates) ? [crates] : crates; | ||
@@ -26,2 +28,6 @@ function wasmFilename(cratePath) { | ||
enforce: 'pre', | ||
configResolved(resolvedConfig) { | ||
config_base = resolvedConfig.base; | ||
config_assetsDir = resolvedConfig.build.assetsDir; | ||
}, | ||
resolveId(id) { | ||
@@ -65,3 +71,3 @@ for (let i = 0; i < cratePaths.length; i++) { | ||
code = code.replace(regex, (match, group1) => { | ||
return `input = "/assets/${group1}"`; | ||
return `input = "${path_1.default.join(config_base, config_assetsDir, group1)}"`; | ||
}); | ||
@@ -68,0 +74,0 @@ fs_extra_1.default.writeFileSync(jsPath, code); |
{ | ||
"name": "vite-plugin-wasm-pack", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "wasm-pack for Vite", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -83,2 +83,11 @@ # 🚚 vite-plugin-wasm-pack | ||
Add script to `package.json` | ||
```json | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build" | ||
} | ||
``` | ||
⚠ **Don't forget to build your [wasm-pack](https://github.com/rustwasm/wasm-pack) crate first!** | ||
@@ -90,12 +99,13 @@ | ||
Add command to `package.json` | ||
Tips: you can add a `wasm` script to `package.json` like this: | ||
```json | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build" | ||
"wasm": "wasm-pack build ./my-crate --target web", | ||
"dev": "yarn wasm && vite", | ||
"build": "vite build" | ||
} | ||
``` | ||
Start dev server, and install `my-crate` that you build earlier. | ||
Then, run: | ||
@@ -106,2 +116,4 @@ ```bash | ||
This will start dev server, and install `my-crate` that you built earlier. | ||
## Complete example | ||
@@ -108,0 +120,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9088
106
123