React

Next JS์—์„œ tailwind ์ ์šฉ ์•ˆ๋ ๋•Œ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•

martinooo 2024. 5. 17. 23:23

๐Ÿคท‍โ™‚๏ธ ๋ณธ๋ก ์— ์•ž์„œ


Tailwind๋ž€?

Tailwind CSS๋Š” React์™€ Next ํ”„๋ ˆ์ž„์›Œํฌ์—์„œ ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” CSS ํ”„๋ ˆ์ž„ ์›Œํฌ์ž…๋‹ˆ๋‹ค.

Tailwind CSS๋Š” ‘utility-first’ ๋ชฉ์ ์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋‹ค๋ฅธ CSS ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ๋‹ฌ๋ฆฌ CSS ํŒŒ์ผ & style ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  class ์†์„ฑ์œผ๋กœ CSS ์Šคํƒ€์ผ๋ง ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

 

Tailwind CSS ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ?

Tailwind CSS ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ํ†ตํ•ด์„œ UI๋ฅผ ๋น ๋ฅด๊ณ  ์œ ์—ฐํ•˜๊ฒŒ ๋””์ž์ธํ•˜๊ณ  ์Šคํƒ€์ผ๋งํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

class(className) ๊ธฐ๋ฐ˜์˜ ํ™”๋ฉด์„ ์Šคํƒ€์ผ๋ง ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ฐœ๋ฐœ์ž์˜ ์ƒ์‚ฐ์„ฑ๊ณผ ๋น ๋ฅด๊ฒŒ ํ™”๋ฉด์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ์žฅ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. 

 

 

๐Ÿคท‍โ™‚๏ธ Tailwind ์‚ฌ์šฉ๋ฒ•


Next.js or React์—์„œ Tailwind CSS ์ ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค. 

 

1. tailwind ์„ค์น˜

npm install -D tailwindcss postcss autoprefixer

npx tailwindcss init -p

 

* ์œ„์— ๋ช…๋ น์–ด๋ฅผ ์ˆœ์„œ๋Œ€๋กœ ํ„ฐ๋ฏธ๋„์— ์ž…๋ ฅํ•ด์„œ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

 

 

Next JS ๋ณด์ผ๋Ÿฌํ”Œ๋ ˆ์ดํŠธ 

https://github.com/yoogukhyeon/next-boilerplate

 

GitHub - yoogukhyeon/next-boilerplate

Contribute to yoogukhyeon/next-boilerplate development by creating an account on GitHub.

github.com

 

 

Next JS ๋ณด์ผ๋Ÿฌํ”Œ๋ ˆ์ดํŠธ ๊ฐœ๋…

https://cometruedream.tistory.com/216

 

๋ณด์ผ๋Ÿฌํ”Œ๋ ˆ์ดํŠธ(Boilerplate code)๋ž€? - ๊ฐœ๋…, ํ•„์š”ํ•œ ์ด์œ 

๐Ÿ‘‹ ๋ณด์ผ๋Ÿฌ ํ”Œ๋ ˆ์ดํŠธ๋ž€? ์ฝ”๋”ฉ์„ ํ•˜๋‹ค ๋ณด๋ฉด ์˜๋ฏธ ์—†๋Š” ์ฝ”๋”ฉ์„ ํ•  ๋•Œ๋„ ์žˆ๊ณ  ๋ถˆํ•„์š”ํ•œ ์ž‘์—…์— ๋•Œ๋ฌธ์— ์—…๋ฌด ์ƒ์‚ฐ์„ฑ์ด ๋–จ์–ด์ง€๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿด ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•ด ๋ณด์ผ๋Ÿฌ ํ”Œ๋ ˆ์ดํŠธ๋กœ ๊ธฐ๋ณธ์ ์ธ

cometruedream.tistory.com

 

 

 

 

 

2. ์„ค์น˜ ํ›„์— 2๊ฐœ์˜ ํŒŒ์ผ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

 

 

3. ์„ค์น˜ ํ›„์— 2๊ฐœ์˜ ํŒŒ์ผ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

postcss.config.js

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  },
}



tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    './app/**/*.{js,ts,jsx,tsx,mdx}',
    './pages/**/*.{js,ts,jsx,tsx,mdx}',
    './components/**/*.{js,ts,jsx,tsx,mdx}',

    // Or if using `src` directory:
    './src/**/*.{js,ts,jsx,tsx,mdx}',
  ],
  theme: {
    extend: {},
  },
  plugins: [],
};

 

* ์œ„์— 2๊ฐœ์˜ ํŒŒ์ผ์— ๊ฐ๊ฐ์— ๊ฐ’์„ ์ ์šฉ์‹œํ‚ค๋ฉด Tailwind CSS ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

 

4. globals.css ์…‹ํŒ…

@tailwind base;
@tailwind components;
@tailwind utilities;

 

* globals.css ํŒŒ์ผ์— ์œ„์— ๊ฐ’๋„ ์…‹ํŒ…์„ํ•ฉ๋‹ˆ๋‹ค.

 

 

 

๐Ÿคท‍โ™‚๏ธ Tailwind CSS ์ ์šฉ์ด ์•ˆ๋ ๋•Œ?


์œ„์— ๋ฐฉ์‹๋Œ€๋กœ ํ–ˆ๋Š”๋ฐ Tailwind CSS ์ ์šฉ์ด ์•ˆ๋˜์„œ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์‚ฝ์งˆ์„ ํ• ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. 

 

Next.js ์—์„œ๋Š” globals.css ํŒŒ์ผ ์œ„์น˜๋„ ์ค‘์š”ํ•ฉ๋‹ˆ๋‹ค.

ํŒŒ์ผ์œ„์น˜๊ฐ€ ์ด์ƒํ•˜๋ฉด Tailwind CSS ์ ์šฉ์ด ์•ˆ๋  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

 

์ถœ์ฒ˜: Next.js ๊ณต์‹๋ฌธ์„œ

Good to know: This is different from the pages directory, where you can only import global styles inside the  _app.js file.

 

 

 

Next.js ๋ฒ„์ „๋งˆ๋‹ค ํŒŒ์ผ์œ„์น˜์— ์ฐจ์ด๊ฐ€ ์žˆ์„์ˆ˜ ์žˆ์ง€๋งŒ ํŒŒ์ผ ์œ„์น˜๊ฐ€ styles ํด๋” ์•ˆ์— ์žˆ๊ฑฐ๋‚˜ ๋‹ค๋ฅธ ํด๋” ์•ˆ์— ์žˆ์„์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

Next.js ๊ณต์‹๋ฌธ์„œ์—์„œ๋„ global.css ํŒŒ์ผ ์œ„์น˜์— ๋Œ€ํ•ด์„œ ํ”ผ๋“œ๋ฐฑ์„ ์ฃผ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

์‰ฝ๊ฒŒ ์„ค๋ช…ํ•˜์ž๋ฉด _app.tsx ํŒŒ์ผ๊ณผ ๊ฐ™์€ ๋Ž์Šค ์œ„์น˜์— global.css ํŒŒ์ผ์ด ์œ„์น˜ํ•ด ์žˆ์–ด์•ผ tailwind CSS ์ ์šฉ ๋ฉ๋‹ˆ๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค.

 

 


 

์žฌ๋ฐŒ๋Š” ์˜ค๋Š˜์˜ ๋ ๋ณ„ ์šด์„ธ ๋ณด๊ณ  ๊ฐ€์„ธ์š”! 

 

 

 

https://cometruedream.tistory.com/243

 

NestJS Lifecycle (์ƒ๋ช…์ฃผ๊ธฐ) ๊ฐœ๋…

๐Ÿคท‍โ™‚๏ธ ๋ณธ๋ก ์— ์•ž์„œ Nest JS ๊ฐœ๋…?Nest JS๋Š” Node JS ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ ์„œ๋ฒ„ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ํ”„๋ ˆ์ž„์›Œํฌ ์ž…๋‹ˆ๋‹ค. ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋Š” ์ƒ๋‹นํžˆ ์˜ค๋žซ๋™์•ˆ Express ๊ธฐ๋ฐ˜์œผ๋กœ ์„œ๋ฒ„ ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ์—์„œ ์••๋„์ ์ธ ์ 

cometruedream.tistory.com

 

 

https://cometruedream.tistory.com/242

 

๋ฆฌ์•กํŠธ Vite Proxy ํ™œ์šฉํ•œ CORS ์˜ค๋ฅ˜ ํ•ด๊ฒฐ

๐Ÿคท‍โ™‚๏ธ ๋ณธ๋ก ์— ์•ž์„œํ”„๋ก ํŠธ์—”๋“œ ๋ฒˆ๋“ค๋Ÿฌ ๊ฐœ๋…๊ณผ webpack vs vite ๋น„๊ต์— ๋Œ€ํ•ด์„œ ๊ณต๋ถ€๋ฅผ ํ•˜๊ณ  ๊ธ€์„ ๋ณด์‹œ๋ฉด ๋” ๋งŽ์€ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค^^ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์„ ์œ„ํ•œ ๋ฒˆ๋“ค๋Ÿฌ ๊ฐœ๋…๊ณผ webpack vs vite ๋น„๊ตhttps://comet

cometruedream.tistory.com

 

 

https://cometruedream.tistory.com/241

 

React ํด๋”๊ตฌ์กฐ FSD ๊ธฐ๋Šฅ ๋ถ„ํ™œ ์„ค๊ณ„ ์•„ํ‚คํ…์ฒ˜

๐Ÿคท‍โ™‚๏ธ ๋ณธ๋ก ์— ์•ž์„œํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•˜๊ธฐ์— ์•ž์„œ ํด๋” ๊ตฌ์กฐ, ์„ค๊ณ„์— ๋Œ€ํ•œ ์•„ํ‚คํ…์ฒ˜๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒƒ์€ ์ƒ๋‹นํžˆ ์–ด๋ ต๋‹ค. ์ด๋ฒˆ ํ”„๋กœ์ ํŠธ์— React FSD ํด๋”๊ตฌ์กฐ ์•„ํ‚คํ…์ฒ˜๋ฅผ ์„ค๊ณ„ํ•  ์˜ˆ์ •์ด๋ผ์„œ FSD ์•„ํ‚คํ…

cometruedream.tistory.com

 

 

https://cometruedream.tistory.com/244

 

์‰ฝ๊ฒŒ ์ดํ•ดํ•˜๊ณ  ์‚ฌ์šฉํ• ์ˆ˜ ์žˆ๋Š” Prisma ๋ช…๋ น์–ด ์ •๋ฆฌ

๐Ÿคท‍โ™‚๏ธ Prisma ๋ช…๋ น์–ด ๋ณธ๋ก ์— ์•ž์„œ Prisma๋ž€?Nest JS ํ”„๋ ˆ์ž„์›Œํฌ์™€ Prisma ORM์„ ํ™œ์šฉํ•ด์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ์ง„ํ–‰ํ•˜๋ฉด์„œ Prisma๋Š” Node JS ๊ธฐ๋ฐ˜์— ํ”„๋ ˆ์ž„์›Œํฌ/๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์™€ ์ƒํ˜ธ์ž‘์šฉ์ด ์ž˜๋˜๋ฉฐ Prisma + DB ์—ฐ๋™์œผ

cometruedream.tistory.com