Skip to content

Commit

Permalink
build: Use Vite instead of Create React App (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleyjones authored Mar 9, 2023
1 parent 8cbf6ee commit b3d1172
Show file tree
Hide file tree
Showing 20 changed files with 3,275 additions and 7,699 deletions.
2 changes: 1 addition & 1 deletion client/.env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
REACT_APP_API_PATH=/api/v1
VITE_API_PATH=/api/v1
1 change: 1 addition & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
/dist

# misc
.DS_Store
Expand Down
29 changes: 0 additions & 29 deletions client/config-overrides.js

This file was deleted.

7 changes: 4 additions & 3 deletions client/public/index.html → client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1"
/>
<meta name="theme-color" content="#000000" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="manifest" href="/manifest.json" />
<title>Talib</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
20 changes: 9 additions & 11 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
"private": true,
"dependencies": {
"@liftedinit/ui": "github:liftedinit/lifted-ui",
"crypto-browserify": "^3.12.0",
"react-app-rewired": "^2.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-query": "^4.0.0-alpha.20",
"@tanstack/react-query": "^4.3.4",
"react-router": "^6.8.1",
"react-router-dom": "^6.8.1",
"react-scripts": "^5.0.1",
"stream-browserify": "^3.0.0",
"typescript": "^4.9.3",
"web-vitals": "^3.1.0"
"typescript": "^4.9.3"
},
"devDependencies": {
"@testing-library/jest-dom": "^5.16.5",
Expand All @@ -24,12 +19,15 @@
"@types/node": "^18.11.9",
"@types/react": "^18.0.25",
"@types/react-dom": "^18.0.9",
"eslint-config-react-app": "^7.0.1"
"@vitejs/plugin-react": "^3.1.0",
"eslint-config-react-app": "^7.0.1",
"vite": "^4.1.4",
"vite-plugin-node-polyfills": "^0.7.0"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test"
"start": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"eslintConfig": {
"extends": [
Expand Down
2 changes: 1 addition & 1 deletion client/src/features/neighborhoods/components/status.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Spinner, Stack } from "@liftedinit/ui";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import { Stat } from "../../../shared";
import { getNeighborhood } from "../queries";

Expand Down
1 change: 0 additions & 1 deletion client/src/react-app-env.d.ts

This file was deleted.

15 changes: 0 additions & 15 deletions client/src/reportWebVitals.ts

This file was deleted.

2 changes: 1 addition & 1 deletion client/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function by<T>(attr: keyof T) {
export function get(path: string, params = {}) {
return async function () {
const query = new URLSearchParams(params).toString();
const url = `${process.env.REACT_APP_API_PATH}/${path}?${query}`;
const url = `${import.meta.env.VITE_API_PATH}/${path}?${query}`;
const res = await fetch(url);
if (res.ok) {
return await res.json();
Expand Down
10 changes: 4 additions & 6 deletions client/src/views/app.provider.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import {
queryClient,
QueryClientProvider,
theme,
ThemeProvider,
} from "@liftedinit/ui";
import { theme, ThemeProvider } from "@liftedinit/ui";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import React from "react";
import { HashRouter } from "react-router-dom";

const queryClient = new QueryClient();

export function AppProvider({ children }: { children: React.ReactNode }) {
return (
<ThemeProvider theme={theme}>
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/block.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Divider, Stack } from "@liftedinit/ui";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import { useParams } from "react-router-dom";
import { getNeighborhoodBlock } from "../features/neighborhoods";
import { Stat, TransactionList } from "../shared";
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/blocks.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box } from "@liftedinit/ui";
import { useState } from "react";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import { getNeighborhoodBlocks } from "../features/neighborhoods";
import { BlockList, Pager } from "../shared";

Expand Down
2 changes: 1 addition & 1 deletion client/src/views/home.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Button, Divider, SimpleGrid } from "@liftedinit/ui";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import { Link } from "react-router-dom";
import {
getNeighborhoodBlocks,
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/transactions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box } from "@liftedinit/ui";
import { useState } from "react";
import { useQuery } from "react-query";
import { useQuery } from "@tanstack/react-query";
import { getNeighborhoodTransactions } from "../features/neighborhoods";
import { Pager, TransactionList } from "../shared";

Expand Down
1 change: 1 addition & 0 deletions client/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
6 changes: 4 additions & 2 deletions client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "es2015"
"target": "esnext",
"types": ["vite/client"]
},
"include": ["src"]
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
9 changes: 9 additions & 0 deletions client/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
8 changes: 8 additions & 0 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { nodePolyfills } from "vite-plugin-node-polyfills";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), nodePolyfills({ protocolImports: true })],
});
Loading

0 comments on commit b3d1172

Please sign in to comment.