Skip to content

Commit 6121491

Browse files
authored
docs: add asset > runtime access setup (PlasmoHQ#87)
I ran into this issue and it took quite a while to figure out, hence I added a new section for this use case.
1 parent d0e43c0 commit 6121491

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/pages/framework/assets.mdx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,22 @@ The files below will be copied into the extension bundle and be available to [`c
5656

5757
See [with-web-accessible-resources](https://github.com/PlasmoHQ/examples/tree/main/with-web-accessible-resources)
5858

59+
### Loading Asset during runtime
60+
If you use a package that dynamically loads an asset (e.g. wasm) during runtime and needs a path to the local asset library, note that you need to make your asset folder available using ~assets, e.g.:
61+
```json
62+
"web_accessible_resources": [
63+
{
64+
"resources": [
65+
"~assets/wasm/*/**",
66+
],
67+
}
68+
],
69+
```
70+
While in your js/ts code you need to refer the folder using the absolute path `/`
71+
```js
72+
wasmPackage.localWASMPath("/assets/wasm/")
73+
```
74+
5975
## Assets from `node_modules`
6076

6177
Sometimes, a node package exposes static assets files you must include in your bundle as web-accessible resources. To do so, specify those assets in the `web_accessible_resources` field of the manifest override in `package.json`:

0 commit comments

Comments
 (0)