Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace react-scripts with vite #8

Merged
merged 3 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ services:
dockerfile: Dockerfile
image: si-sorting-frontend
container_name: si-sorting-frontend
command: ["npm", "run", "start"]
ports:
- "3000:3000"
- "5173:5173"
environment:
DEPLOY_MODE: compose
volumes:
Expand Down
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ services:
frontend:
image: ghcr.io/catalystneuro/si-sorting-frontend:latest
container_name: si-sorting-frontend
command: ["npm", "run", "start"]
ports:
- "3000:3000"
- "5173:5173"
environment:
DEPLOY_MODE: compose
depends_on:
Expand Down Expand Up @@ -38,6 +39,7 @@ services:
AWS_DEFAULT_REGION: ${AWS_DEFAULT_REGION}
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
DANDI_API_KEY: ${DANDI_API_KEY}
volumes:
- ./results:/results
- ./logs:/logs
Expand Down
18 changes: 18 additions & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
// root: true,
// env: { browser: true, es2020: true },
// extends: [
// 'eslint:recommended',
// 'plugin:@typescript-eslint/recommended',
// 'plugin:react-hooks/recommended',
// ],
// ignorePatterns: ['dist', '.eslintrc.cjs'],
// parser: '@typescript-eslint/parser',
// plugins: ['react-refresh'],
// rules: {
// 'react-refresh/only-export-components': [
// 'warn',
// { allowConstantExport: true },
// ],
// },
}
9 changes: 5 additions & 4 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ FROM node:19.2-bullseye-slim

WORKDIR /app

COPY package*.json ./
COPY yarn.lock ./
COPY package.json yarn.lock ./
RUN yarn install

COPY . ./

# RUN yarn build
EXPOSE 3000

CMD ["yarn", "start"]
EXPOSE 5173

CMD ["npm", "run", "start"]
13 changes: 13 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SpikeInterface Cloud</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/index.tsx"></script>
</body>
</html>
33 changes: 24 additions & 9 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
"name": "sorterapp",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"start": "npm run dev",
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"react:start": "react-scripts start",
"react:build": "react-scripts build",
"react:test": "react-scripts test",
"react:eject": "react-scripts eject"
},
"dependencies": {
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
Expand All @@ -16,22 +28,25 @@
"@testing-library/user-event": "^13.2.1",
"@types/jest": "^27.0.1",
"@types/node": "^16.7.13",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"axios": "^1.3.4",
"markdown-to-jsx": "^7.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.9.0",
"react-scripts": "5.0.1",
"typescript": "^4.4.2",
"web-vitals": "^2.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"devDependencies": {
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react-swc": "^3.3.2",
"eslint": "^8.45.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"typescript": "^4.4.2",
"vite": "^4.4.5"
},
"eslintConfig": {
"extends": [
Expand All @@ -51,4 +66,4 @@
"last 1 safari version"
]
}
}
}
1 change: 1 addition & 0 deletions frontend/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions frontend/src/common/config/environment.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ export interface IEnvironment {
USE_MOCK: boolean
}


const global = (globalThis.process ?? import.meta)

/**
* Stores all environment variables for easier access
*/
export const environment: IEnvironment = {
NODE_ENV: process.env.NODE_ENV as INodeEnv,
DEPLOY_MODE: process.env.DEPLOY_MODE as IApiEnv,
USE_MOCK: !!process.env.REACT_APP_USE_MOCK
NODE_ENV: global.env?.NODE_ENV as INodeEnv,
DEPLOY_MODE: global.env?.DEPLOY_MODE as IApiEnv,
USE_MOCK: !!global.env?.REACT_APP_USE_MOCK
}
5 changes: 5 additions & 0 deletions frontend/src/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import vite from 'vite'

export default vite.defineConfig({
base: './'
})
35 changes: 17 additions & 18 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
]
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
10 changes: 10 additions & 0 deletions frontend/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
26 changes: 26 additions & 0 deletions frontend/tsconfig.old.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}
15 changes: 15 additions & 0 deletions frontend/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
watch: {
usePolling: true,
},
host: true, // needed for the Docker Container port mapping to work
strictPort: true,
port: 5173, // replace this port with any number you want
},
})
Loading