Skip to content

Commit 22f88dd

Browse files
authored
Merge pull request #5857 from marmelab/simple-example-vite
Simple example vite
2 parents ff9c427 + bcd73ae commit 22f88dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1098
-1481
lines changed

examples/demo/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"@types/inflection": "^1.5.28",
99
"@types/recharts": "^1.8.10",
1010
"data-generator-retail": "^3.9.0",
11-
"fakerest": "^2.2.0",
11+
"fakerest": "^3.0.0",
1212
"fetch-mock": "~6.3.0",
1313
"json-graphql-server": "~2.1.3",
1414
"proxy-polyfill": "^0.3.0",

examples/simple/.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-react"]
3+
}

examples/simple/.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.DS_Store
3+
dist
4+
dist-ssr
5+
*.local

examples/simple/babel.config.js

-24
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<!DOCTYPE html>
2-
<html>
3-
4-
<head>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
56
<title>React Admin</title>
67
<style>
7-
body {
8-
margin: 0;
9-
}
8+
body {
9+
margin: 0;
10+
}
1011
</style>
11-
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" />
12-
</head>
13-
14-
<body>
15-
<div id="root">
16-
</div>
12+
</head>
13+
<body>
14+
<div id="root"></div>
15+
<script>window.global = window</script>
16+
<script src="/bundle.js"></script>
1717
<!-- 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 -->
1818
<script>
1919
var WebFontConfig = {
@@ -28,6 +28,5 @@
2828
s.parentNode.insertBefore(wf, s);
2929
})();
3030
</script>
31-
</body>
32-
31+
</body>
3332
</html>

examples/simple/index.html

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>React Admin</title>
7+
<style>
8+
body {
9+
margin: 0;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
<div id="root"></div>
15+
<script>window.global = window</script>
16+
<script type="module" src="/src/index.tsx"></script>
17+
<!-- 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 -->
18+
<script>
19+
var WebFontConfig = {
20+
google: { families: ['Roboto:300,400,500,700:latin'] }
21+
};
22+
(function () {
23+
var wf = document.createElement('script');
24+
wf.src = 'https://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
25+
wf.type = 'text/javascript';
26+
wf.async = 'true';
27+
var s = document.getElementsByTagName('script')[0];
28+
s.parentNode.insertBefore(wf, s);
29+
})();
30+
</script>
31+
</body>
32+
</html>

examples/simple/package.json

+34-47
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,36 @@
11
{
2-
"name": "simple",
3-
"private": true,
4-
"version": "3.0.0",
5-
"description": "",
6-
"main": "index.html",
7-
"scripts": {
8-
"dev": "./node_modules/.bin/webpack-dev-server --progress --color --hot --watch --mode development",
9-
"start": "USE_ALIAS=true ./node_modules/.bin/webpack-dev-server --progress --color --hot --watch --mode development",
10-
"serve": "./node_modules/.bin/serve --listen 8080 ./dist",
11-
"build": "./node_modules/.bin/webpack-cli --color --mode development --hide-modules true"
12-
},
13-
"author": "",
14-
"license": "MIT",
15-
"devDependencies": {
16-
"@babel/cli": "^7.10.5",
17-
"@babel/core": "^7.11.4",
18-
"@babel/plugin-proposal-class-properties": "^7.10.4",
19-
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
20-
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
21-
"@babel/preset-env": "^7.11.0",
22-
"@babel/preset-react": "^7.10.4",
23-
"@babel/preset-typescript": "^7.10.4",
24-
"babel-loader": "^8.0.4",
25-
"html-loader": "~1.3.0",
26-
"html-webpack-plugin": "~4.3.0",
27-
"ignore-not-found-export-plugin": "^1.0.1",
28-
"serve": "^10.1.2",
29-
"style-loader": "~1.2.1",
30-
"wait-on": "^3.2.0",
31-
"webpack": "~4.5.0",
32-
"webpack-bundle-analyzer": "^3.3.2",
33-
"webpack-cli": "~2.0.13",
34-
"webpack-dev-server": "~3.1.11"
35-
},
36-
"dependencies": {
37-
"@babel/polyfill": "^7.10.4",
38-
"@material-ui/core": "^4.11.2",
39-
"@material-ui/icons": "^4.11.2",
40-
"ra-data-fakerest": "^3.9.0",
41-
"ra-i18n-polyglot": "^3.9.0",
42-
"ra-input-rich-text": "^3.9.0",
43-
"ra-language-english": "^3.9.0",
44-
"ra-language-french": "^3.9.0",
45-
"react": "^17.0.0",
46-
"react-admin": "^3.9.0",
47-
"react-dom": "^17.0.0"
48-
}
2+
"name": "simple",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"dev": "./node_modules/.bin/webpack-dev-server --progress --color --hot --watch --mode development",
6+
"start": "vite",
7+
"build": "vite build",
8+
"serve": "vite preview"
9+
},
10+
"dependencies": {
11+
"@material-ui/core": "^4.11.2",
12+
"@material-ui/icons": "^4.11.2",
13+
"ra-data-fakerest": "^3.9.0",
14+
"ra-i18n-polyglot": "^3.9.0",
15+
"ra-input-rich-text": "^3.9.0",
16+
"ra-language-english": "^3.9.0",
17+
"ra-language-french": "^3.9.0",
18+
"react": "^17.0.0",
19+
"react-admin": "^3.9.0",
20+
"react-dom": "^17.0.0"
21+
},
22+
"devDependencies": {
23+
"@babel/preset-react": "^7.12.10",
24+
"@vitejs/plugin-react-refresh": "^1.2.2",
25+
"ts-loader": "^8.0.14",
26+
"html-loader": "~1.3.0",
27+
"html-webpack-plugin": "~4.3.0",
28+
"ignore-not-found-export-plugin": "^1.0.1",
29+
"style-loader": "~1.2.1",
30+
"typescript": "^4.1.3",
31+
"vite": "^2.0.0-beta.62",
32+
"webpack": "~4.5.0",
33+
"webpack-cli": "~2.0.13",
34+
"webpack-dev-server": "~3.1.11"
35+
}
4936
}

examples/simple/sandbox.config.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"infiniteLoopProtection": true,
3+
"hardReloadOnChange": false,
4+
"view": "browser",
5+
"template": "node",
6+
"container": {
7+
"node": "14"
8+
}
9+
}
File renamed without changes.
File renamed without changes.

examples/simple/src/comments/CommentEdit.js examples/simple/src/comments/CommentEdit.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import Card from '@material-ui/core/Card';
2-
import Typography from '@material-ui/core/Typography';
1+
import { Card, Typography } from '@material-ui/core';
32
import { makeStyles } from '@material-ui/core/styles';
43
import * as React from 'react';
54
import {

examples/simple/src/comments/PostQuickCreateCancelButton.js examples/simple/src/comments/PostQuickCreateCancelButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as React from 'react';
22
import PropTypes from 'prop-types';
33

4-
import Button from '@material-ui/core/Button';
4+
import { Button } from '@material-ui/core';
55
import IconCancel from '@material-ui/icons/Cancel';
66
import { makeStyles } from '@material-ui/core/styles';
77

examples/simple/src/comments/PostReferenceInput.js examples/simple/src/comments/PostReferenceInput.tsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ import { Fragment, useState, useCallback } from 'react';
33
import { FormSpy, useForm } from 'react-final-form';
44

55
import { makeStyles } from '@material-ui/core/styles';
6-
import Button from '@material-ui/core/Button';
7-
import Dialog from '@material-ui/core/Dialog';
8-
import DialogTitle from '@material-ui/core/DialogTitle';
9-
import DialogContent from '@material-ui/core/DialogContent';
10-
import DialogActions from '@material-ui/core/DialogActions';
6+
import {
7+
Button,
8+
Dialog,
9+
DialogTitle,
10+
DialogContent,
11+
DialogActions,
12+
} from '@material-ui/core';
1113

1214
import { ReferenceInput, SelectInput, useTranslate } from 'react-admin'; // eslint-disable-line import/no-unresolved
1315

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/simple/src/i18nProvider.js examples/simple/src/i18nProvider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import polyglotI18nProvider from 'ra-i18n-polyglot';
22
import englishMessages from './i18n/en';
33

44
const messages = {
5-
fr: () => import('./i18n/fr.js').then(messages => messages.default),
5+
fr: () => import('./i18n/fr').then(messages => messages.default),
66
};
77

88
export default polyglotI18nProvider(locale => {
File renamed without changes.
File renamed without changes.

examples/simple/src/posts/PostList.js examples/simple/src/posts/PostList.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import * as React from 'react';
22
import { Children, Fragment, cloneElement, memo } from 'react';
33
import BookIcon from '@material-ui/icons/Book';
4-
import Chip from '@material-ui/core/Chip';
5-
import { useMediaQuery } from '@material-ui/core';
4+
import { Chip, useMediaQuery } from '@material-ui/core';
65
import { makeStyles } from '@material-ui/core/styles';
76
import lodashGet from 'lodash/get';
87
import jsonExport from 'jsonexport/dist';

examples/simple/src/posts/PostShow.js examples/simple/src/posts/PostShow.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
useLocale,
2424
} from 'react-admin';
2525
import { Link } from 'react-router-dom';
26-
import Button from '@material-ui/core/Button';
26+
import { Button } from '@material-ui/core';
2727
import PostTitle from './PostTitle';
2828

2929
const CreateRelatedComment = ({ record }) => (
File renamed without changes.

examples/simple/src/posts/TagReferenceInput.js examples/simple/src/posts/TagReferenceInput.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { useState } from 'react';
33
import { useForm } from 'react-final-form';
44
import { AutocompleteArrayInput, ReferenceArrayInput } from 'react-admin';
5-
import Button from '@material-ui/core/Button';
5+
import { Button } from '@material-ui/core';
66
import { makeStyles } from '@material-ui/core/styles';
77

88
const useStyles = makeStyles({
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/simple/src/users/Aside.js examples/simple/src/users/Aside.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import Typography from '@material-ui/core/Typography';
2+
import { Typography } from '@material-ui/core';
33
import { makeStyles } from '@material-ui/core/styles';
44

55
const useStyles = makeStyles(theme => ({
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

examples/simple/tsconfig.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"outDir": "lib",
5+
"rootDir": "src",
6+
"declaration": true,
7+
"allowJs": false,
8+
"jsx": "react",
9+
"lib": [
10+
"es2017",
11+
"dom"
12+
],
13+
"moduleResolution": "node",
14+
"allowSyntheticDefaultImports": true,
15+
"esModuleInterop": true,
16+
"skipLibCheck": true
17+
},
18+
"exclude": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.spec.js"],
19+
"include": ["src"]
20+
}

examples/simple/vite.config.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import reactRefresh from '@vitejs/plugin-react-refresh';
2+
import path from 'path';
3+
4+
/**
5+
* https://vitejs.dev/config/
6+
* @type { import('vite').UserConfig }
7+
*/
8+
export default {
9+
plugins: [reactRefresh()],
10+
alias: [
11+
{
12+
find: /^react-admin$/,
13+
replacement: path.resolve(
14+
__dirname,
15+
'../../packages/react-admin/src'
16+
),
17+
},
18+
{
19+
find: /^ra-(.*)$/,
20+
replacement: path.resolve(__dirname, '../../packages/ra-$1/src'),
21+
},
22+
{
23+
find: /^@material-ui\/icons\/(.*)/,
24+
replacement: '@material-ui/icons/esm/$1',
25+
},
26+
{
27+
find: /^@material-ui\/core\/(.+)/,
28+
replacement: '@material-ui/core/es/$1',
29+
},
30+
{
31+
find: /^@material-ui\/core$/,
32+
replacement: '@material-ui/core/es',
33+
},
34+
],
35+
};

0 commit comments

Comments
 (0)