Skip to content

Commit 7cbe82e

Browse files
authored
feat: replace react-scripts with vite (aws-samples#37)
1 parent 9beb8cd commit 7cbe82e

File tree

6 files changed

+5551
-15421
lines changed

6 files changed

+5551
-15421
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />
5-
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
5+
<link rel="shortcut icon" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#000000" />
88
<meta
99
name="description"
1010
content="Notes App - modular AWS SDK for JavaScript (v3)"
1111
/>
1212
<link rel="apple-touch-icon" href="logo192.png" />
13-
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
13+
<link rel="manifest" href="/manifest.json" />
1414
<title>Notes App - modular AWS SDK for JavaScript (v3)</title>
1515
<link
1616
rel="stylesheet"
@@ -22,5 +22,6 @@
2222
<body>
2323
<noscript>You need to enable JavaScript to run this app.</noscript>
2424
<div id="root"></div>
25+
<script type="module" src="/src/index.tsx"></script>
2526
</body>
2627
</html>

packages/frontend/package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,20 @@
1414
"@aws-sdk/util-create-request": "3.23.0",
1515
"@aws-sdk/util-format-url": "3.23.0",
1616
"@reach/router": "1.3.4",
17+
"buffer": "6.0.3",
1718
"microphone-stream": "6.0.1",
19+
"process": "0.11.10",
1820
"react": "17.0.1",
1921
"react-bootstrap": "1.4.0",
2022
"react-dom": "17.0.1"
2123
},
2224
"scripts": {
2325
"prepare:frontend": "cd .. && yarn prepare:frontend",
24-
"build": "react-scripts build",
26+
"build": "tsc && vite build",
2527
"build:frontend": "cd .. && yarn build:frontend",
26-
"start": "react-scripts start",
28+
"start": "vite",
2729
"start:frontend": "cd .. && yarn start:frontend",
28-
"serve": "ws -d build -o",
30+
"serve": "vite preview",
2931
"serve:frontend": "cd .. && yarn serve:frontend",
3032
"cdk": "cd .. && yarn cdk"
3133
},
@@ -59,9 +61,9 @@
5961
"@types/reach__router": "1.3.6",
6062
"@types/react": "17.0.0",
6163
"@types/react-dom": "17.0.0",
62-
"local-web-server": "^4.2.1",
64+
"@vitejs/plugin-react-refresh": "1.3.6",
6365
"react-bootstrap-icons": "1.3.0",
64-
"react-scripts": "4.0.1",
65-
"typescript": "~4.1.2"
66+
"typescript": "~4.1.2",
67+
"vite": "2.4.4"
6668
}
6769
}

packages/frontend/src/index.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1+
import { Buffer } from "buffer";
2+
import process from "process";
13
import React from "react";
24
import ReactDOM from "react-dom";
35
import { Routes } from "./Routes";
46

7+
// Polyfills required for MicrophoneStream
8+
if (typeof (window as any).global === "undefined") {
9+
(window as any).global = window;
10+
}
11+
if (typeof (window as any).Buffer === "undefined") {
12+
(window as any).Buffer = Buffer;
13+
}
14+
if (typeof (window as any).process === "undefined") {
15+
(window as any).process = process;
16+
}
17+
518
ReactDOM.render(
619
<div className="container" style={{ height: "100vh" }}>
720
<Routes />

packages/frontend/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es5",
3+
"target": "ESNext",
44
"lib": ["dom", "dom.iterable", "esnext"],
55
"allowJs": true,
66
"skipLibCheck": true,

packages/frontend/vite.config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { defineConfig } from "vite";
2+
import reactRefresh from "@vitejs/plugin-react-refresh";
3+
4+
// https://vitejs.dev/config/
5+
export default defineConfig({
6+
plugins: [reactRefresh()],
7+
resolve: {
8+
alias: {
9+
"./runtimeConfig": "./runtimeConfig.browser",
10+
},
11+
},
12+
});

0 commit comments

Comments
 (0)