Skip to content

Commit

Permalink
docs(jsx-pragma): Add section on using with vite (#2119)
Browse files Browse the repository at this point in the history
Co-authored-by: Lachlan Campbell <lachlanjc@hey.com>
  • Loading branch information
PeterlitsZo and lachlanjc committed Feb 9, 2022
1 parent c926747 commit dd8ad9e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/docs/src/pages/guides/jsx-pragma.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,22 @@ In `jsconfig.json` or `tsconfig.json` (since Next.js 12.0.4):
}
}
```

### Using Vite

Vite use [`esbuild`](https://esbuild.github.io) to bundle source files.
[Per Vite documentation](https://vitejs.dev/guide/features.html#jsx), configure the pragma project-wide like this:

```js filename=vite.config.js
import { defineConfig } from 'vite'

export default defineConfig({
esbuild: {
jsxFactory: 'jsx',
jsxInject: `import { jsx } from 'theme-ui'`,
},
})
```

`esbuild` will use `theme-ui`’s `jsx` for every component by programatically injecting `import { jsx } from 'theme-ui'`
to the start of every JSX file.

0 comments on commit dd8ad9e

Please sign in to comment.