Skip to content

Commit dd8ad9e

Browse files
docs(jsx-pragma): Add section on using with vite (#2119)
Co-authored-by: Lachlan Campbell <[email protected]>
1 parent c926747 commit dd8ad9e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/docs/src/pages/guides/jsx-pragma.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,22 @@ In `jsconfig.json` or `tsconfig.json` (since Next.js 12.0.4):
186186
}
187187
}
188188
```
189+
190+
### Using Vite
191+
192+
Vite use [`esbuild`](https://esbuild.github.io) to bundle source files.
193+
[Per Vite documentation](https://vitejs.dev/guide/features.html#jsx), configure the pragma project-wide like this:
194+
195+
```js filename=vite.config.js
196+
import { defineConfig } from 'vite'
197+
198+
export default defineConfig({
199+
esbuild: {
200+
jsxFactory: 'jsx',
201+
jsxInject: `import { jsx } from 'theme-ui'`,
202+
},
203+
})
204+
```
205+
206+
`esbuild` will use `theme-ui`’s `jsx` for every component by programatically injecting `import { jsx } from 'theme-ui'`
207+
to the start of every JSX file.

0 commit comments

Comments
 (0)