Skip to content

Commit

Permalink
refactor: switch to vite (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian authored Apr 3, 2023
1 parent 59744d9 commit c1f1be6
Show file tree
Hide file tree
Showing 20 changed files with 15,047 additions and 30,438 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ module.exports = {
settings: {
'import/resolver': {
typescript: {}
},
react: {
version: 'detect'
}
}
};
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ node_modules
/coverage

# production
build
dist

# misc
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
2. Run `npm install`
3. Login to the AWS account containing the visual regression S3 bucket
4. Run `npm run dev`
5. Application will be running at `http://localhost:3000`, and it will hot reload when you make changes.
5. Application will be running at `http://localhost:5173`, and it will hot reload when you make changes.

You can also run the app using docker-compose using `npm run build:docker`!

Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ RUN chown -R admin .
COPY --chown=admin . .
USER admin

ENV NODE_ENV "production"
ENV PORT 8080

RUN npm ci
Expand Down
4 changes: 2 additions & 2 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default defineConfig({

component: {
devServer: {
framework: 'create-react-app',
bundler: 'webpack'
framework: 'react',
bundler: 'vite'
},
viewportWidth: 1440,
viewportHeight: 990
Expand Down
14 changes: 14 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/resources/Island.svg" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Comparadise</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
45,301 changes: 14,970 additions & 30,331 deletions package-lock.json

Large diffs are not rendered by default.

43 changes: 23 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,54 +1,57 @@
{
"name": "comparadise",
"proxy": "http://localhost:8080",
"dependencies": {
"@aws-sdk/client-s3": "3.178.0",
"@aws-sdk/client-s3": "3.304.0",
"@emotion/react": "11.10.6",
"@emotion/styled": "11.10.6",
"@mui/icons-material": "5.10.9",
"@mui/material": "5.10.11",
"@mui/icons-material": "5.11.11",
"@mui/material": "5.11.15",
"@octokit/rest": "19.0.7",
"@trpc/client": "10.3.0",
"@trpc/react-query": "10.3.0",
"@trpc/server": "10.3.0",
"@trpc/client": "10.18.0",
"@trpc/react-query": "10.18.0",
"@trpc/server": "10.18.0",
"@types/cors": "2.8.12",
"@types/express": "4.17.17",
"@types/lodash.groupby": "4.6.7",
"@types/node": "18.7.21",
"@types/node": "18.15.11",
"@types/react": "18.0.21",
"@types/react-dom": "18.0.8",
"@vitejs/plugin-react-swc": "3.2.0",
"cors": "2.8.5",
"express-rate-limit": "6.6.0",
"express-rate-limit": "6.7.0",
"lodash.groupby": "4.6.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-scripts": "5.0.1",
"ts-node": "10.9.1",
"typescript": "4.9.5",
"typescript": "5.0.3",
"use-query-params": "2.2.1",
"vite": "4.2.1",
"zod": "3.21.4"
},
"devDependencies": {
"@testing-library/cypress": "9.0.0",
"@types/jest": "28.1.7",
"@types/jest": "29.5.0",
"@types/testing-library__cypress": "5.0.9",
"cypress": "12.8.1",
"jest": "28.1.3",
"@typescript-eslint/eslint-plugin": "5.57.0",
"cypress": "12.9.0",
"eslint": "8.37.0",
"eslint-plugin-react": "7.32.2",
"jest": "29.5.0",
"npm-watch": "0.11.0",
"prettier": "2.8.0",
"prettier": "2.8.7",
"start-server-and-test": "2.0.0",
"ts-jest": "28.0.8"
"ts-jest": "29.1.0"
},
"scripts": {
"build": "react-scripts build",
"build": "tsc && vite build",
"build:docker": "docker build . --tag comparadise && docker-compose up",
"cypress:e2e": "cypress run --e2e",
"cypress:open": "CYPRESS_BASE_URL=http://localhost:3000 cypress open",
"dev": "DISABLE_ESLINT_PLUGIN=true npm run start:client & npm-watch",
"cypress:open": "CYPRESS_BASE_URL=http://localhost:5173 cypress open",
"dev": "npm run start:client & npm-watch",
"format": "prettier --write .",
"format-check": "prettier --check .",
"lint": "eslint .",
"start:client": "react-scripts start",
"start:client": "vite",
"start:server": "ts-node server/index.ts",
"test:client": "cypress run --component",
"test:integration": "start-server-and-test build:docker http://localhost:8080 cypress:e2e",
Expand Down
46 changes: 0 additions & 46 deletions public/index.html

This file was deleted.

15 changes: 0 additions & 15 deletions public/manifest.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/robots.txt

This file was deleted.

4 changes: 2 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ app.use(rateLimit({ windowMs: oneMinute, max: 1000 }));
app.use(cors());
app.use('/trpc', trpcExpress.createExpressMiddleware({ router }));

app.use(express.static(path.resolve(__dirname, '../build')));
app.use(express.static(path.resolve(__dirname, '../dist')));
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, '../build', 'index.html'));
res.sendFile(path.resolve(__dirname, '../dist', 'index.html'));
});

const PORT = 8080;
Expand Down
12 changes: 0 additions & 12 deletions src/index.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import './index.css';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
2 changes: 1 addition & 1 deletion src/providers/ClientProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const ClientProvider = ({ children }: React.PropsWithChildren) => {
trpc.createClient({
links: [
httpBatchLink({
url: '/trpc'
url: 'http://localhost:8080/trpc'
})
]
})
Expand Down
1 change: 0 additions & 1 deletion src/react-app-env.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand All @@ -18,5 +18,6 @@
"noEmit": true
},
"include": ["server", "src"],
"exclude": ["./**/*.test.ts", "cypress"]
"exclude": ["./**/*.test.ts", "cypress"],
"references": [{ "path": "./tsconfig.node.json" }]
}
9 changes: 9 additions & 0 deletions 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"]
}
7 changes: 7 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()]
});

0 comments on commit c1f1be6

Please sign in to comment.