Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,21 @@ The encoder automatically tries these locations:
3. Package worker file (fallback, may require CORS setup)
4. Inline helper (shows setup instructions if above fail)

## Setup for Vite/PWA projects

If you're bundling your application with tools like **Vite**, **Webpack**, or **Rollup**, you can let the bundler resolve the worker file directly instead of copying it manually. Construct the worker URL using `import.meta.url`:

```ts
const workerUrl = new URL(
'./node_modules/webcodecs-encoder/dist/worker.js',
import.meta.url
).toString();

await encoder.initialize({ workerScriptUrl: workerUrl });
```

This allows your bundler to include the worker script in the build and serve it correctly without any manual steps.

## Basic Usage

### Traditional API (Constructor-based)
Expand Down