Skip to content

Commit 9641523

Browse files
authored
chore(examples): migrate react-scripts and vue/cli examples to vite (#1264)
1 parent 148b677 commit 9641523

34 files changed

+419
-5608
lines changed

examples/react-17/.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/react-17/.env.example

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/react-17/README.md

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,32 @@
1-
# Getting Started with Create React App
1+
# Autocomplete with React 17 example
22

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3+
This example shows how to integrate Autocomplete with React 17.
44

5-
## Available Scripts
5+
## Demo
66

7-
In the project directory, you can run:
7+
[Access the demo](https://codesandbox.io/s/github/algolia/autocomplete/tree/next/examples/react-17)
88

9-
### `yarn start`
9+
## How to run this example locally
1010

11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11+
### 1. Clone this repository
1312

14-
The page will reload if you make edits.\
15-
You will also see any lint errors in the console.
13+
```sh
14+
git clone [email protected]:algolia/autocomplete.git
15+
```
1616

17-
### `yarn test`
17+
### 2. Install the dependencies and run the server
1818

19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19+
```sh
20+
yarn
21+
yarn workspace @algolia/autocomplete-example-react-17 start
22+
```
2123

22-
### `yarn build`
24+
Alternatively, you may use npm:
2325

24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
26+
```sh
27+
cd examples/react-17
28+
npm install
29+
npm start
30+
```
2631

27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
29-
30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
31-
32-
### `yarn eject`
33-
34-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
35-
36-
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
37-
38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
39-
40-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
41-
42-
## Learn More
43-
44-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
45-
46-
To learn React, check out the [React documentation](https://reactjs.org/).
32+
Open <http://localhost:3000> to see your app.
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8" />
4+
<meta charset="UTF-8" />
5+
<link rel="shortcut icon" type="image/x-icon" href="/favicon.png" />
6+
<link rel="manifest" href="/manifest.json" />
57
<meta name="viewport" content="width=device-width, initial-scale=1" />
68
<meta name="theme-color" content="#000000" />
7-
8-
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
9-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
10-
119
<title>React 17 | Autocomplete</title>
1210
</head>
1311
<body>
14-
<noscript>You need to enable JavaScript to run this app.</noscript>
1512
<div id="root"></div>
13+
<script type="module" src="/src/index.tsx"></script>
1614
</body>
1715
</html>

examples/react-17/package.json

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,31 @@
33
"description": "Autocomplete example with React 17",
44
"version": "1.17.2",
55
"private": true,
6+
"scripts": {
7+
"dev": "vite",
8+
"start": "vite",
9+
"build": "tsc && vite build",
10+
"preview": "vite preview"
11+
},
612
"dependencies": {
713
"@algolia/autocomplete-core": "1.17.2",
814
"@algolia/autocomplete-preset-algolia": "1.17.2",
915
"@algolia/autocomplete-theme-classic": "1.17.2",
10-
"@algolia/client-search": "4.16.0",
1116
"algoliasearch": "4.16.0",
1217
"react": "17.0.2",
13-
"react-dom": "17.0.2",
14-
"react-scripts": "4.0.3"
18+
"react-dom": "17.0.2"
1519
},
16-
"scripts": {
17-
"start": "react-scripts start",
18-
"build": "react-scripts build",
19-
"test": "react-scripts test",
20-
"eject": "react-scripts eject"
20+
"devDependencies": {
21+
"@algolia/client-search": "4.16.0",
22+
"@types/react": "^17.0.0",
23+
"@types/react-dom": "^17.0.0",
24+
"@vitejs/plugin-react": "1.0.7",
25+
"typescript": "^4.4.2",
26+
"vite": "2.8.0"
2127
},
22-
"browserslist": {
23-
"production": [
24-
">0.2%",
25-
"not dead",
26-
"not op_mini all"
27-
],
28-
"development": [
29-
"last 1 chrome version",
30-
"last 1 firefox version",
31-
"last 1 safari version"
32-
]
33-
}
28+
"keywords": [
29+
"algolia",
30+
"autocomplete",
31+
"react"
32+
]
3433
}

examples/react-17/react-app-env.d.ts

Whitespace-only changes.

examples/react-17/src/react-app-env.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/react-17/vite.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import react from '@vitejs/plugin-react';
2+
import { defineConfig } from 'vite';
3+
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
6+
plugins: [react()],
7+
});

examples/react-instantsearch/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ git clone [email protected]:algolia/autocomplete.git
2020

2121
```sh
2222
yarn
23-
yarn workspace @algolia/autocomplete-example-react-instantsearch-hooks dev
23+
yarn workspace @algolia/autocomplete-example-react-instantsearch dev
2424
```
2525

2626
Alternatively, you may use npm:
2727

2828
```sh
29-
cd examples/react-instantsearch-hooks
29+
cd examples/react-instantsearch
3030
npm install
3131
npm run dev
3232
```

examples/react/.env

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)