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

Chore: CRA -> vite로 마이그레이션 #100

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
12 changes: 1 addition & 11 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@ module.exports = {
env: {
browser: true,
es2021: true,
node: true,
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
],
overrides: [
{
env: {
node: true,
},
files: ['.eslintrc.{js,cjs}'],
parserOptions: {
sourceType: 'script',
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
Expand Down
21 changes: 21 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.svg" />
<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"
/>
<link rel="apple-touch-icon" href="/logo192.png" />
<link rel="manifest" href="/manifest.json" />
<title>Chat Diary</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>
19,157 changes: 4,543 additions & 14,614 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/node": "^16.18.68",
"@types/node": "^18.0.0",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@types/react-router-dom": "^5.3.3",
Expand All @@ -17,7 +17,6 @@
"react-dom": "^18.2.0",
"react-query": "^3.39.3",
"react-router-dom": "^6.21.1",
"react-scripts": "5.0.1",
"react-slick": "^0.29.0",
"sass": "^1.69.5",
"slick-carousel": "^1.8.1",
Expand All @@ -27,10 +26,9 @@
"zustand": "^4.4.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"start": "vite",
"build": "tsc && vite build",
"serve": "vite preview"
},
"eslintConfig": {
"extends": [
Expand All @@ -51,10 +49,17 @@
]
},
"devDependencies": {
"@svgr/rollup": "^8.1.0",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@vitejs/plugin-react": "^4.3.1",
"eslint": "^8.56.0",
"eslint-plugin-react": "latest",
"prettier": "^3.1.1"
"prettier": "^3.1.1",
"vite": "^5.3.0",
"vite-plugin-env-compatible": "^2.0.1",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-svgr": "^4.2.0",
"vite-tsconfig-paths": "^4.3.2"
}
}
43 changes: 0 additions & 43 deletions public/index.html

This file was deleted.

9 changes: 4 additions & 5 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ declare module '*.scss' {
const content: { [className: string]: string };
export = content;
}
declare module '*.svg' {
export const ReactComponent: REact.FC<React.SVGProps<SVGSVGElement>>;
const src: string;
export default src;
}
// declare module '*.svg' {
// const content: React.FC<React.SVGProps<SVGElement>>;
// export default content;
// }
1 change: 0 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { QueryClient, QueryClientProvider } from 'react-query';
import './index.css';
Expand Down
10 changes: 5 additions & 5 deletions src/pages/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import DialogBtn from '../../components/common/Buttons/DialogBtn/DialogBtn';
const Login = () => {
const [isKakao, setIsKakao] = useState(false);
// oauth 요청 URL
const kakaoURL = `https://kauth.kakao.com/oauth/authorize?client_id=${process.env.REACT_APP_REST_API_KEY}&redirect_uri=${process.env.REACT_APP_REDIRECT_URL}&response_type=code`
const handleLogin = ()=>{
window.location.href = kakaoURL
}
const kakaoURL = `https://kauth.kakao.com/oauth/authorize?client_id=${process.env.REACT_APP_REST_API_KEY}&redirect_uri=${process.env.REACT_APP_REDIRECT_URL}&response_type=code`;

const handleLogin = () => {
window.location.href = kakaoURL;
};

return (
<div className={styles.wholeContainer}>
Expand Down
16 changes: 8 additions & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"target": "ESNext",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"types": ["vite/client", "vite-plugin-svgr/client"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
Expand Down
18 changes: 18 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import viteTsconfigPaths from 'vite-tsconfig-paths';
import svgr from '@svgr/rollup';
import envCompatible from 'vite-plugin-env-compatible';

export default defineConfig({
plugins: [
react(),
viteTsconfigPaths(),
svgr(),
envCompatible({ prefix: 'REACT_APP' }),
],
server: {
open: true,
port: 3000,
},
});
11 changes: 11 additions & 0 deletions vite.env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly REACT_APP_HTTP_API_KEY: string;
readonly REACT_APP_WS_API_KEY: string;
// 다른 환경 변수들도 여기에 추가
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}