개발 ·κ³΅λΆ€/WEB

[Tailwindcss] ν…ŒμΌμœˆλ“œ μ„€μΉ˜ 및 적용

LUNA Dev πŸ“ 2023. 1. 12. 01:52
728x90
λ°˜μ‘ν˜•

 

μ„œλΉ„μŠ€ν•˜λ‚˜λ₯Ό λ§Œλ“€μ–΄λ³΄κΈ° μœ„ν•΄ λΆ€νŠΈμŠ€νŠΈλž©μ΄ μ•„λ‹Œ Tailwincss μ‚¬μš©ν•΄ λ§Œλ“œλ €κ³  ν•˜λŠ”λ° μ„€μΉ˜ 및 적용 방법을 κΉŒλ¨Ήμ§€ μ•ŠκΈ° μœ„ν•΄ μž‘μ„±


 

1. Tailwind μ„€μΉ˜

  - Tailwind μ„€μΉ˜ ν•  폴더에 μ»€λ§¨λ“œ μ°½μ΄λ‚˜ vscode μ»€λ§¨λ“œμ°½μ— μ•„λž˜μ½”λ“œ μž‘μ„±

npm install -D tailwindcss
npx tailwindcss init

 

2. ν…œν”Œλ¦Ώ 경둜 ꡬ성

  - tailwind.config.js 에 μ•„λž˜ μ½”λ“œ μž‘μ„±

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./src/**/*.{html,js}"],
  theme: {
    extend: {},
  },
  plugins: [],
}

 

3. tailwind λ ˆμ΄μ–΄λ₯Ό μΆ”κ°€ν•˜κΈ° μœ„ν•œ 폴더 생성 및 css 파일 생성

  - λ‚˜λŠ” src/css/tailwind.css νŒŒμΌμ„ 생성함

  - tailwind.css νŒŒμΌμ— μ•„λž˜μ™€ 같이 μž‘μ„±

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

 

4. Tailwind CLI λΉŒλ“œ

  - 3λ²ˆμ— μƒμ„±ν•œ 파일 경둜 ν™•μΈν•˜κ³  μž‘μ„±

  - μ•„λž˜ λͺ…λ Ήμ–΄ μ‹€ν–‰μ‹œ λΉŒλ“œκ°€ 되고 /dist/ouput.css 폴더와 파일이 생성

npx tailwindcss -i ./src/css/tailwind.css -o ./dist/output.css --watch

 

5. HTMLμ—μ„œ Tailwind μ‚¬μš©

  - src/index.html 파일 μƒμ„±ν•΄μ„œ tailwindλ₯Ό λΉŒλ“œν•œ /dist/output.css 경둜 link μ—°κ²°

<!doctype html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="/dist/output.css" rel="stylesheet">
</head>
<body>
  <h1 class="text-3xl font-bold underline">
    Hello world!
  </h1>
</body>
</html>

 

κ²°κ³Όλ¬Ό :


좜처

 

Installation - Tailwind CSS

The simplest and fastest way to get up and running with Tailwind CSS from scratch is with the Tailwind CLI tool.

tailwindcss.com

 

728x90
λ°˜μ‘ν˜•