유틸리티 기반 개발 방식으로 미리 세팅된 유틸리티 클래스를 HTML 코드 내에서 스타일링을 할 수 있다.
사용하지 않는 유틸리티는 output이 알아서 없애고 사용하는 유틸리티만 남겨 중복 코드를 줄일 수 있다.
Tailwind CSS 업데이트로 4버전 부터는 더이상 tailwind.config.js 파일 사용하지 않는다
Tailwind CSS IntelliSense
npm install tailwindcss @tailwindcss/cli --save-dev
기본 파일
mkdir src src/assets src/styles src/scripts touch src/index.html src/styles/input.css echo {} > package.jsonhtml
<link rel="stylesheet" href="./styles/output.css" />input.css
@import "tailwindcss";
npm i -D live-server npm-run-all
빌드, 서버 관련 명령 등록
html 파일을 컴파일하면 input.css가 감지하고 output.css가 만들어진다. 이 과정이build/* 빌드 명령어 */ npx tailwindcss -i ./src/styles/input.css -o ./src/styles/output.css
--watch명령을 통해 컴파일 할 때마다 빌드를 해서 서버를 구동해준다.{ "scripts": { "dev": "run-p serve watch", "serve": "live-server ./src --port=8090 --host=localhost --no-browser", "tailwind": "tailwindcss -i ./src/styles/input.css -o ./src/styles/output.css", "watch" : "npm run tailwind -- --watch" }, "devDependencies": { "@tailwindcss/cli": "^4.0.12", "live-server": "^1.2.2", "npm-run-all": "^4.1.5", "tailwindcss": "^4.0.12" } }
저장소 생성
git init
gitignore 파일 생성npx add-gitignore node windows osx visualstudiocode
{ "files.exclude": { "**/.git": true, "**/.svn": true, "**/.hg": true, "**/.DS_Store": true, "**/Thumbs.db": true, "**/node_modules": false, "**/output.css": false }, "files.associations": { "*.css": "tailwindcss" }, "editor.quickSuggestions": { "strings": "on" }, "tailwindCSS.includeLanguages": { "plaintext": "html" }, "files.watcherExclude": { "**/output.css": true } }
필수는 아니지만 속도가 더 빠르고 정리를 잘 해준다
npm install -g pnpm@latest-10
✅ Tailwind CSS: Emmet Completions
✅ Tailwind CSS: Hovers
✅ Tailwind CSS: Suggestions