-
-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Vite docs * Add startup command to Stackblitz template
- Loading branch information
Mathis Møller
committed
Nov 22, 2021
1 parent
759ee14
commit c39c66b
Showing
4 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
title: Vite | ||
description: How to use Jotai with Vite | ||
nav: 3.9 | ||
--- | ||
|
||
You can use the plugins from the `jotai/babel` bundle to enhance your developer experience when using Vite and Jotai. | ||
|
||
In your `vite.config.ts`: | ||
|
||
```ts | ||
import { defineConfig } from 'vite'; | ||
import react from '@vitejs/plugin-react'; | ||
import jotaiDebugLabel from 'jotai/babel/plugin-debug-label'; | ||
import jotaiReactRefresh from 'jotai/babel/plugin-react-refresh'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
react({ babel: { plugins: [jotaiDebugLabel, jotaiReactRefresh] } }), | ||
], | ||
// ... The rest of your configuration | ||
}); | ||
``` | ||
|
||
There's a template below to try it yourself. | ||
|
||
## Examples | ||
|
||
### Vite Template | ||
|
||
<Stackblitz id="vitejs-vite-xhhxve" file="vite.config.ts" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import LazyLoad from 'react-lazyload' | ||
|
||
export const Stackblitz = ({ id, file }) => { | ||
return ( | ||
<div className="mb-8 overflow-hidden shadow-lg rounded-md sm:rounded-lg border-b border-gray-200"> | ||
<LazyLoad height={400} once> | ||
<iframe | ||
title={id} | ||
className="w-full h-[400px]" | ||
src={`https://stackblitz.com/edit/${id}?embed=1${ | ||
file ? `&file=${file}` : '' | ||
}&terminal=dev`} | ||
allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking" | ||
sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" | ||
/> | ||
</LazyLoad> | ||
</div> | ||
) | ||
} |
c39c66b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: