Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(jsx-pragma): Add section on using with vite #2119

Merged
merged 2 commits into from
Feb 9, 2022
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
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.