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: tanstack-query, MSW, 절대 경로 설정 #10

Merged
merged 3 commits into from
Jul 23, 2024
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
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ module.exports = {
},
parserOptions: {
tsconfigRootDir: './',
project: ['./tsconfig.json', './tsconfig.app.json', './tsconfig.node.json'],
project: ['./tsconfig.json', './tsconfig.app.json', './tsconfig.node.json', './tsconfig.base.json']
},
};
51 changes: 51 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
},
"dependencies": {
"@reduxjs/toolkit": "^2.2.6",
"@tanstack/react-query": "^5.51.11",
"@tanstack/react-query-devtools": "^5.51.11",
"classnames": "^2.5.1",
"dotenv": "^16.4.5",
"react": "^18.3.1",
Expand Down
5 changes: 3 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { createRoot } from 'react-dom/client';
import { Provider } from 'react-redux';
import App from './App';
import { store } from './store';
import ReactQueryProvider from './provider/queryProvider';

createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<ReactQueryProvider showDevTools>
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>,
</ReactQueryProvider>,
);
38 changes: 38 additions & 0 deletions src/provider/queryProvider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import React, { useState } from 'react';

interface ReactQueryProviderProps {
children: React.ReactNode;
showDevTools?: boolean;
}

function ReactQueryProvider({
showDevTools,
children,
}: ReactQueryProviderProps) {
const [client] = useState(
new QueryClient({
defaultOptions: {
queries: {
refetchOnWindowFocus: false,
retryOnMount: true,
refetchOnReconnect: false,
retry: false,
},
},
}),
);
return (
<QueryClientProvider client={client}>
{showDevTools && <ReactQueryDevtools buttonPosition="bottom-left" />}
{children}
</QueryClientProvider>
);
}

ReactQueryProvider.defaultProps = {
showDevTools: false,
};

export default ReactQueryProvider;
3 changes: 2 additions & 1 deletion tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
Expand All @@ -23,5 +24,5 @@
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
"include": ["src/**/*"]
}
25 changes: 25 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"lib": ["DOM", "DOM.Iterable", "ES2020"],
"module": "ESNext",
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",

/* absolute paths */
"baseUrl": "./src",
"paths": {
"@/*": ["/*"],
"@/components/*": ["components/*"],
"@/assets/*": ["assets/*"],
"@/constants/*": ["constants/*"],
"@/mocks/*": ["mocks/*"]
}
}
}
1 change: 1 addition & 0 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"composite": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
Expand Down
10 changes: 10 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { resolve } from 'path';

export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'@/components': resolve(__dirname, 'src/components'),
'@/assets': resolve(__dirname, 'src/assets'),
'@/constants': resolve(__dirname, 'src/constants'),
'@/mocks': resolve(__dirname, 'src/mocks'),
},
},
test: {
globals: true,
environment: 'jsdom',
Expand Down