Skip to content

Commit

Permalink
docs(readme): document configs
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark authored Jan 9, 2024
1 parent 3bd6388 commit a05fbae
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Use [JSX](https://facebook.github.io/jsx/) in [Phaser](https://phaser.io/).
With JSX:

```jsx
// index.jsx
import Phaser from 'phaser';
import { Text, render } from 'phaser-jsx';

Expand All @@ -36,6 +37,7 @@ new Phaser.Game({
Without JSX:

```js
// index.js
import Phaser from 'phaser';
import { jsx, render } from 'phaser-jsx';

Expand Down Expand Up @@ -95,12 +97,49 @@ UMD:

## TypeScript

To get better type support, import the GameObject from `phaser-jsx` instead of `phaser`:
To get better type support, import the [GameObject](https://photonstorm.github.io/phaser3-docs/Phaser.GameObjects.html) from `phaser-jsx` instead of `phaser`:

```ts
import { Text } from 'phaser-jsx';
```

> [!TIP]
> All GameObjects exported from `phaser-jsx` are aliases of GameObjects from `phaser`.
Update `tsconfig.json`:

```json
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "phaser-jsx"
}
}
```

## Vite

Update `vite.config.mjs`:

```js
import { defineConfig } from 'vite';

export default defineConfig({
esbuild: {
jsxImportSource: 'phaser-jsx',
},
});
```

### JSX Pragma

If you're not using `jsxImportSource`, you can set JSX pragma at the top of your file:

```jsx
/** @jsx jsx */
import { jsx } from 'phaser-jsx';
```

## Release

Release is automated with [Release Please](https://github.com/googleapis/release-please).
Expand Down

0 comments on commit a05fbae

Please sign in to comment.