1.0.6 โ€ข Published 8 months ago

cra-template-lasbe v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

โšก cra-template-lasbe

๐Ÿ“Œ git repository

๐Ÿ“Œ npm

๐Ÿ“Œ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

$ npx create-react-app my-app --template lasbe

๐Ÿ“Œ ํ…œํ”Œ๋ฆฟ ์ ์šฉ ๋ชฉ๋ก

  • React (^18.2.0)
  • TypeScript (^4.9.5)
  • .prettierrc
  • Craco
  • Axios
  • styled-components
  • @types/styled-components (dev)
  • react-spinners
  • react-router-dom
  • recoil
  • @tanstack/react-query
  • @tanstack/react-query-devtools (dev)

๐Ÿ”Ž index.tsx

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { RecoilRoot } from 'recoil';
import { BrowserRouter } from 'react-router-dom';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';

const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);

const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      suspense: true,
      staleTime: 5 * 60 * 1000,
      cacheTime: 5 * 60 * 1000,
    },
  },
});

root.render(
  <React.StrictMode>
    <QueryClientProvider client={queryClient}>
      <RecoilRoot>
        <BrowserRouter>
          <App />
        </BrowserRouter>
      </RecoilRoot>
      <ReactQueryDevtools initialIsOpen={false} />
    </QueryClientProvider>
  </React.StrictMode>,
);
  • react-router-dom -ย <BrowserRouter />ย in index.tsx
  • recoil -ย <RecoilRoot />ย in index.tsx
  • @tanstack/react-query -ย <QueryClientProvider />ย in index.tsx
  • @tanstack/react-query-devtools (dev) -ย <ReactQueryDevtools />ย in index.tsx

๐Ÿ”Ž ์ ˆ๋Œ€ ๊ฒฝ๋กœ

์ ˆ๋Œ€ ๊ฒฝ๋กœ์™€ ๊ด€๋ จ ๋œ ์„ค์ •์€ /craco.config.js, /tsconfig.paths.json ํŒŒ์ผ์— ์œ„์น˜ํ•ฉ๋‹ˆ๋‹ค.

  • craco.config.js

const path = require('path');
module.exports = {
  webpack: {
    alias: {
      '@apis': path.resolve(__dirname, 'src/apis'),
      '@components': path.resolve(__dirname, 'src/components'),
      '@constants': path.resolve(__dirname, 'src/constants'),
      '@hooks': path.resolve(__dirname, 'src/hooks'),
      '@pages': path.resolve(__dirname, 'src/pages'),
      '@states': path.resolve(__dirname, 'src/states'),
      '@styles': path.resolve(__dirname, 'src/styles'),
      '@utils': path.resolve(__dirname, 'src/utils'),
    },
  },
};
  • tsconfig.paths.json

{
  "compilerOptions": {
    "baseUrl": "./src",
    "paths": {
      "@apis": ["./apis/index.ts"],
      "@apis/*": ["./apis/*"],

      "@components": ["./components/index.ts"],
      "@components/*": ["./components/*"],

      "@constants": ["./constants/index.ts"],
      "@constants/*": ["./constants/*"],

      "@hooks": ["./hooks/index.ts"],
      "@hooks/*": ["./hooks/*"],

      "@pages": ["./pages/index.ts"],
      "@pages/*": ["./pages/*"],

      "@states": ["./states/index.ts"],
      "@states/*": ["./states/*"],

      "@styles": ["./styles/index.ts"],
      "@styles/*": ["./styles/*"],

      "@utils": ["./utils/index.ts"],
      "@utils/*": ["./utils/*"]
    }
  }
}

์ œ๊ฐ€ ์ฃผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ตฌ์กฐ์— ๋งž๊ฒŒ @xxx ํ˜•ํƒœ๋กœ ์ ˆ๋Œ€ ๊ฒฝ๋กœ๋ฅผ ์„ค์ •ํ•ด ์ฃผ์—ˆ์œผ๋ฉฐ, tsconfig์—๋Š” ํด๋” ์ธ๋ฑ์Šค๊นŒ์ง€ ์ ์šฉ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

๋งŒ์•ฝ ๋‹ค๋ฅธ ๊ตฌ์กฐ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ๋‘ ํŒŒ์ผ์—์„œ ์ˆ˜์ •ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

๐Ÿ”Ž .prettierrc

{
  "Semicolons": true,
  "singleQuote": true,
  "trailingComma": "all",
  "Tabs": true,
  "tabWidth": 2,
  "printWidth": 140
}

์ž…๋ง›์— ๋งž๊ฒŒ ์ˆ˜์ •ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago