Skip to content

Commit

Permalink
Use Vite in Simple Example
Browse files Browse the repository at this point in the history
  • Loading branch information
djhi committed Feb 4, 2021
1 parent b89ed15 commit 6db6668
Show file tree
Hide file tree
Showing 52 changed files with 390 additions and 3,823 deletions.
3 changes: 3 additions & 0 deletions examples/simple/.babelrc
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-react"]
}
5 changes: 5 additions & 0 deletions examples/simple/.gitignore
@@ -0,0 +1,5 @@
node_modules
.DS_Store
dist
dist-ssr
*.local
24 changes: 0 additions & 24 deletions examples/simple/babel.config.js

This file was deleted.

28 changes: 11 additions & 17 deletions examples/simple/src/index.html → examples/simple/index.html
@@ -1,19 +1,14 @@
<!DOCTYPE html>
<html>

<head>
<title>React Admin</title>
<style>
body {
margin: 0;
}
</style>
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no" />
</head>

<body>
<div id="root">
</div>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
</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>
var WebFontConfig = {
Expand All @@ -28,6 +23,5 @@
s.parentNode.insertBefore(wf, s);
})();
</script>
</body>

</body>
</html>
71 changes: 24 additions & 47 deletions examples/simple/package.json
@@ -1,49 +1,26 @@
{
"name": "simple",
"private": true,
"version": "3.0.0",
"description": "",
"main": "index.html",
"scripts": {
"dev": "./node_modules/.bin/webpack-dev-server --progress --color --hot --watch --mode development",
"start": "USE_ALIAS=true ./node_modules/.bin/webpack-dev-server --progress --color --hot --watch --mode development",
"serve": "./node_modules/.bin/serve --listen 8080 ./dist",
"build": "./node_modules/.bin/webpack-cli --color --mode development --hide-modules true"
},
"author": "",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.11.4",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-env": "^7.11.0",
"@babel/preset-react": "^7.10.4",
"@babel/preset-typescript": "^7.10.4",
"babel-loader": "^8.0.4",
"html-loader": "~1.3.0",
"html-webpack-plugin": "~4.3.0",
"ignore-not-found-export-plugin": "^1.0.1",
"serve": "^10.1.2",
"style-loader": "~1.2.1",
"wait-on": "^3.2.0",
"webpack": "~4.5.0",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "~2.0.13",
"webpack-dev-server": "~3.1.11"
},
"dependencies": {
"@babel/polyfill": "^7.10.4",
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"ra-data-fakerest": "^3.9.0",
"ra-i18n-polyglot": "^3.9.0",
"ra-input-rich-text": "^3.9.0",
"ra-language-english": "^3.9.0",
"ra-language-french": "^3.9.0",
"react": "^17.0.0",
"react-admin": "^3.9.0",
"react-dom": "^17.0.0"
}
"name": "simple-vite",
"version": "0.0.0",
"scripts": {
"start": "vite",
"build": "vite build",
"serve": "vite preview"
},
"dependencies": {
"@material-ui/core": "^4.11.2",
"@material-ui/icons": "^4.11.2",
"ra-data-fakerest": "^3.9.0",
"ra-i18n-polyglot": "^3.9.0",
"ra-input-rich-text": "^3.9.0",
"ra-language-english": "^3.9.0",
"ra-language-french": "^3.9.0",
"react": "^17.0.0",
"react-admin": "^3.9.0",
"react-dom": "^17.0.0"
},
"devDependencies": {
"@babel/preset-react": "^7.12.10",
"@vitejs/plugin-react-refresh": "^1.2.2",
"vite": "^2.0.0-beta.62"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,4 @@
import Card from '@material-ui/core/Card';
import Typography from '@material-ui/core/Typography';
import { Card, Typography } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import * as React from 'react';
import {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';

import Button from '@material-ui/core/Button';
import { Button } from '@material-ui/core';
import IconCancel from '@material-ui/icons/Cancel';
import { makeStyles } from '@material-ui/core/styles';

Expand Down
Expand Up @@ -3,11 +3,13 @@ import { Fragment, useState, useCallback } from 'react';
import { FormSpy, useForm } from 'react-final-form';

import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
import DialogTitle from '@material-ui/core/DialogTitle';
import DialogContent from '@material-ui/core/DialogContent';
import DialogActions from '@material-ui/core/DialogActions';
import {
Button,
Dialog,
DialogTitle,
DialogContent,
DialogActions,
} from '@material-ui/core';

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

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -2,7 +2,7 @@ import polyglotI18nProvider from 'ra-i18n-polyglot';
import englishMessages from './i18n/en';

const messages = {
fr: () => import('./i18n/fr.js').then(messages => messages.default),
fr: () => import('./i18n/fr').then(messages => messages.default),
};

export default polyglotI18nProvider(locale => {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,8 +1,7 @@
import * as React from 'react';
import { Children, Fragment, cloneElement, memo } from 'react';
import BookIcon from '@material-ui/icons/Book';
import Chip from '@material-ui/core/Chip';
import { useMediaQuery } from '@material-ui/core';
import { Chip, useMediaQuery } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import lodashGet from 'lodash/get';
import jsonExport from 'jsonexport/dist';
Expand Down
Expand Up @@ -23,7 +23,7 @@ import {
useLocale,
} from 'react-admin';
import { Link } from 'react-router-dom';
import Button from '@material-ui/core/Button';
import { Button } from '@material-ui/core';
import PostTitle from './PostTitle';

const CreateRelatedComment = ({ record }) => (
Expand Down
File renamed without changes.
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { useState } from 'react';
import { useForm } from 'react-final-form';
import { AutocompleteArrayInput, ReferenceArrayInput } from 'react-admin';
import Button from '@material-ui/core/Button';
import { Button } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles({
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -4,6 +4,7 @@ import {
SimpleShowLayout,
TextField,
TranslatableFields,
BooleanField,
} from 'react-admin'; // eslint-disable-line import/no-unresolved

const TagShow = props => (
Expand All @@ -13,6 +14,7 @@ const TagShow = props => (
<TranslatableFields locales={['en', 'fr']}>
<TextField source="name" />
</TranslatableFields>
<BooleanField source="published" />
</SimpleShowLayout>
</Show>
);
Expand Down
File renamed without changes.
@@ -1,5 +1,5 @@
import * as React from 'react';
import Typography from '@material-ui/core/Typography';
import { Typography } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';

const useStyles = makeStyles(theme => ({
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions examples/simple/tsconfig.json
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"outDir": "lib",
"rootDir": "src",
"declaration": true,
"allowJs": false,
},
"exclude": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.spec.js"],
"include": ["src"]
}
35 changes: 35 additions & 0 deletions examples/simple/vite.config.js
@@ -0,0 +1,35 @@
import reactRefresh from '@vitejs/plugin-react-refresh';
import path from 'path';

/**
* https://vitejs.dev/config/
* @type { import('vite').UserConfig }
*/
export default {
plugins: [reactRefresh()],
alias: [
{
find: /^react-admin$/,
replacement: path.resolve(
__dirname,
'../../packages/react-admin/src'
),
},
{
find: /^ra-(.*)$/,
replacement: path.resolve(__dirname, '../../packages/ra-$1/src'),
},
{
find: /^@material-ui\/icons\/(.*)/,
replacement: '@material-ui/icons/esm/$1',
},
{
find: /^@material-ui\/core\/(.+)/,
replacement: '@material-ui/core/es/$1',
},
{
find: /^@material-ui\/core$/,
replacement: '@material-ui/core/es',
},
],
};
87 changes: 0 additions & 87 deletions examples/simple/webpack.config.js

This file was deleted.

0 comments on commit 6db6668

Please sign in to comment.