Skip to content

Commit

Permalink
feat(Vite): migrate example app to vite
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell Lee authored and TheEvilDev committed Jul 11, 2023
1 parent 70e637d commit d2e65be
Show file tree
Hide file tree
Showing 16 changed files with 15,481 additions and 23,117 deletions.
6 changes: 3 additions & 3 deletions examples/react-app/.env.local.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
REACT_APP_AWS_ACCESS_KEY_ID=
REACT_APP_AWS_SECRET_ACCESS_KEY=
REACT_APP_AWS_SESSION_TOKEN=
VITE_AWS_ACCESS_KEY_ID=
VITE_AWS_SECRET_ACCESS_KEY=
VITE_AWS_SESSION_TOKEN=
47 changes: 0 additions & 47 deletions examples/react-app/hot-link.js

This file was deleted.

29 changes: 29 additions & 0 deletions examples/react-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<title>IoT AppKit Sample Application</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
<script type="module" src="/src/index.tsx"></script>
</html>
21 changes: 0 additions & 21 deletions examples/react-app/link.sh

This file was deleted.

15 changes: 7 additions & 8 deletions examples/react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
"zustand": "^3.7.2"
},
"scripts": {
"start": "GENERATE_SOURCEMAP=false react-app-rewired start",
"build": "react-app-rewired build",
"eject": "react-scripts eject",
"link": "./link.sh",
"hot-link": "node hot-link"
"start": "vite",
"build": "vite build",
"serve": "vite preview"
},
"eslintConfig": {
"extends": [
Expand Down Expand Up @@ -53,13 +51,14 @@
"@types/node": "^18.16.18",
"@types/react": "^18.2.12",
"@types/react-dom": "^18.2.5",
"@vitejs/plugin-react": "^4.0.3",
"adjust-sourcemap-loader": "^5.0.0",
"node-polyfill-webpack-plugin": "^2.0.1",
"nodemon": "^2.0.22",
"postcss-initial": "^4.0.1",
"react-app-rewired": "^2.2.1",
"react-scripts": "5.0.1",
"rollup-plugin-node-polyfills": "^0.2.1",
"sass": "^1.63.4",
"typescript": "^4.8.3"
"typescript": "^4.8.3",
"vite": "^4.4.3"
}
}
43 changes: 0 additions & 43 deletions examples/react-app/public/index.html

This file was deleted.

8 changes: 0 additions & 8 deletions examples/react-app/public/manifest.json

This file was deleted.

3 changes: 0 additions & 3 deletions examples/react-app/public/robots.txt

This file was deleted.

2 changes: 1 addition & 1 deletion examples/react-app/src/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const region = 'us-east-1';
export const workspaceId = 'CookieFactory';

// SceneViewer
export const sceneId = 'Mixer';
export const sceneId = 'CookieFactory';
export const viewport: Viewport = {
start: new Date('<your-start-time>'), // the start time to query data from your workspace
end: new Date('<your-end-time>'), // the end time to query data from your workspace
Expand Down
12 changes: 6 additions & 6 deletions examples/react-app/src/getEnvCredentials.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export const getEnvCredentials = () => {
if (
process.env.REACT_APP_AWS_ACCESS_KEY_ID == null ||
process.env.REACT_APP_AWS_SECRET_ACCESS_KEY == null
import.meta.env.VITE_AWS_ACCESS_KEY_ID == null ||
import.meta.env.VITE_AWS_SECRET_ACCESS_KEY == null
) {
throw new Error(
'Missing credentials: must provide the following env variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY within .env.local'
'Missing credentials: must provide the following env variables: VITE_AWS_ACCESS_KEY_ID, VITE_AWS_SECRET_ACCESS_KEY within .env.local'
);
}
return {
// Provided by `.env.local` environment variable file
accessKeyId: process.env.REACT_APP_AWS_ACCESS_KEY_ID,
secretAccessKey: process.env.REACT_APP_AWS_SECRET_ACCESS_KEY,
sessionToken: process.env.REACT_APP_AWS_SESSION_TOKEN,
accessKeyId: import.meta.env.VITE_AWS_ACCESS_KEY_ID,
secretAccessKey: import.meta.env.VITE_AWS_SECRET_ACCESS_KEY,
sessionToken: import.meta.env.VITE_AWS_SESSION_TOKEN,
};
};
1 change: 1 addition & 0 deletions examples/react-app/src/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
window.global ||= window;
1 change: 1 addition & 0 deletions examples/react-app/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './global';
import { createRoot } from 'react-dom/client';
import './index.css';
import reportWebVitals from './reportWebVitals';
Expand Down
1 change: 1 addition & 0 deletions examples/react-app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dom.iterable",
"esnext"
],
"types": ["node", "vite/client"],
"allowJs": true,
"module": "esnext",
"moduleResolution": "node",
Expand Down
24 changes: 24 additions & 0 deletions examples/react-app/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig(() => {
return {
build: {
outDir: 'build',
},
assetsInclude: ['**/*.hdr'],
plugins: [react()],
server: {
port: 3000,
host: true,
},
resolve: {
alias: {
path: 'rollup-plugin-node-polyfills/polyfills/path',
},
},
preview: {
port: 4000,
},
};
});

0 comments on commit d2e65be

Please sign in to comment.