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

Fix documentation about Vite #8692

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion docs/Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Here is an overview of the result:

## Setting Up

React-admin uses React. We'll use [vite.js](https://vitejs.dev/) to create an empty React app, and install the `react-admin` package:
React-admin uses React. We'll use [Vite](https://vitejs.dev/) to create an empty React app, and install the `react-admin` package:

```sh
yarn create vite test-admin --template react-ts
Expand Down
22 changes: 13 additions & 9 deletions docs/Vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,19 @@ Next, add the `Roboto` font to your `index.html` file:

**Tip:** You can also install the `Roboto` font locally by following the instructions from the [MUI starter guide](https://mui.com/material-ui/getting-started/installation/#roboto-font).

Finally, add the following line to the `index.html` file:
Now, start the server with `yarn dev`, browse to `http://localhost:5173/`, and you should see the working admin:

![Working Page](./img/nextjs-react-admin.webp)

Your app is now up and running, you can start tweaking it.

## Troubleshooting

### Error about `global` Being `undefined`

This usually means some dependency is not [configured correctly for browser usage](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#browser). You should try to contact the maintainer so that they update their build process.

You can fix this error by adding the following line to the `index.html` file:

```diff
// in ./index.html
Expand All @@ -116,11 +128,3 @@ Finally, add the following line to the `index.html` file:
</body>
</html>
```

This helps increase the compatibility of some dependencies used by React Admin with Vite.

Now, start the server with `yarn dev`, browse to `http://localhost:5173/`, and you should see the working admin:

![Working Page](./img/nextjs-react-admin.webp)

Your app is now up and running, you can start tweaking it.
1 change: 0 additions & 1 deletion examples/simple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
</head>
<body>
<div id="root"></div>
<script>window.global = window</script>
<script type="module" src="/src/index.tsx"></script>
<!-- This script adds the Roboto font to our project. For more detail go to this site: http://www.google.com/fonts#UsePlace:use/Collection:Roboto:400,300,500 -->
<script>
Expand Down