# vite-plugin-turbowarp-packager

A Vite plugin that uses `@turbowarp/packager` to generate TurboWarp-ready HTML from a `.sb3` file.  
During build, it outputs `dist/turbowarp-packager.html`.

## Installation

```bash
bun add -D vite-plugin-turbowarp-packager
```

## Usage

### Use with `hikkaku/vite` (recommended)

The `hikkaku` plugin automatically sets the output path for `project.sb3`.

```ts
import hikkaku from 'hikkaku/vite'
import { defineConfig } from 'vite-plus'
import { pluginTurbowarpPackager } from 'vite-plugin-turbowarp-packager'

export default defineConfig({
  plugins: [
    hikkaku({
      entry: 'src.ts',
    }),
    pluginTurbowarpPackager(),
  ],
})
```

When using both plugins, place `hikkaku(...)` before `pluginTurbowarpPackager(...)`.

### Set `sb3Entry` manually

If your `.sb3` is generated by another process, set `sb3Entry` directly.

```ts
import { defineConfig } from 'vite-plus'
import { pluginTurbowarpPackager } from 'vite-plugin-turbowarp-packager'

export default defineConfig({
  plugins: [
    pluginTurbowarpPackager({
      sb3Entry: 'dist/project.sb3',
      packagerOptions: {
        turbo: true,
      },
    }),
  ],
})
```

## Options

```ts
interface TurbowarpPackagerOptions {
  sb3Entry?: string
  outputFileName?: string
  packagerOptions?: Partial<PackagerOptions>
}
```

- `sb3Entry`: Path to the `.sb3` file to package. Build fails if omitted.
- `outputFileName`: Output HTML filename. Defaults to `turbowarp-packager.html`.
- `packagerOptions`: Options passed to `@turbowarp/packager`.

## Limitations

- `packagerOptions.target` currently supports only `html`.
- This plugin is intended for build-time packaging (not dev-server conversion).
- This plugin does not empty `build.outDir` when generating HTML, so outputs created by other plugins are preserved.
