Skip to content

Commit

Permalink
Merge pull request #97 from boostcampwm-2024/feat/#64/react-init
Browse files Browse the repository at this point in the history
[Feat] React + Vite + Typescript 초기 설정
  • Loading branch information
seoko97 authored Nov 5, 2024
2 parents e99b22c + 0ea7d7c commit cb31271
Show file tree
Hide file tree
Showing 18 changed files with 1,287 additions and 36 deletions.
7 changes: 0 additions & 7 deletions apps/client/.eslintrc.js

This file was deleted.

16 changes: 0 additions & 16 deletions apps/client/package.json

This file was deleted.

Empty file removed apps/client/src/index.ts
Empty file.
10 changes: 0 additions & 10 deletions apps/client/tsconfig.json

This file was deleted.

34 changes: 34 additions & 0 deletions apps/web/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const path = require('path');

const baseConfig = path.resolve(__dirname, 'tsconfig.json');
const appConfig = path.resolve(__dirname, 'tsconfig.app.json');
const nodeConfig = path.resolve(__dirname, 'tsconfig.node.json');

/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
extends: [require.resolve('@repo/lint'), 'plugin:react-hooks/recommended'],
plugins: ['react-refresh'],
settings: {
react: {
version: '18.3.0',
},
'import/resolver': {
typescript: {
project: [baseConfig, appConfig, nodeConfig],
node: {
paths: ['src'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
},
},
},
parserOptions: {
project: [baseConfig, appConfig, nodeConfig],
},
ignorePatterns: ['dist', '.eslintrc.cjs'],
rules: {
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'import/no-unresolved': ['error', { ignore: ['^/'] }],
},
};
24 changes: 24 additions & 0 deletions apps/web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
50 changes: 50 additions & 0 deletions apps/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:

- Configure the top-level `parserOptions` property like this:

```js
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
});
```

- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:

```js
// eslint.config.js
import react from 'eslint-plugin-react';

export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
});
```
13 changes: 13 additions & 0 deletions apps/web/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ticle</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
33 changes: 33 additions & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@app/web",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@repo/shards": "workspace:*",
"@repo/types": "workspace:*",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@repo/lint": "workspace:*",
"@repo/tsconfig": "workspace:*",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.3",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"eslint": "^8.57.0",
"globals": "^15.11.0",
"typescript": "~5.6.2",
"vite": "^5.4.10",
"vite-tsconfig-paths": "^5.0.1"
}
}
5 changes: 5 additions & 0 deletions apps/web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function App() {
return <></>;
}

export default App;
16 changes: 16 additions & 0 deletions apps/web/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';

import App from '@/App';

const root = document.getElementById('root');

if (!root) {
throw new Error('No root element found');
}

createRoot(root).render(
<StrictMode>
<App />
</StrictMode>
);
1 change: 1 addition & 0 deletions apps/web/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
32 changes: 32 additions & 0 deletions apps/web/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"extends": "@repo/tsconfig/base.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true,

"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src"]
}
5 changes: 5 additions & 0 deletions apps/web/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "@repo/tsconfig/base.json",
"files": [],
"references": [{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.node.json" }]
}
24 changes: 24 additions & 0 deletions apps/web/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}
8 changes: 8 additions & 0 deletions apps/web/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tsconfigPaths()],
});
1 change: 0 additions & 1 deletion packages/eslint/paths.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// packages/eslint/rules/paths.js
/** @type {import("eslint").Linter.Config} */
module.exports = {
settings: {
Expand Down
Loading

0 comments on commit cb31271

Please sign in to comment.