프로젝트 설정 중 CRA에서는 tailwindcss가 작동되는데, vite에서는 작동이 되지 않았다.
1. 공식 문서 방법
기존 tailwind 설치 이외에 2개의 패키지 설치가 필요하다.
npm install -D tailwindcss postcss autoprefixer
Install Tailwind CSS with Vite - Tailwind CSS
Setting up Tailwind CSS in a Vite project.
tailwindcss.com
2. 기존 방법 + vite.config 수정
1번 방법을 찾기 전에 다른 방법을 찾아서 적용했다.
이미 공식문서대로 설치 후 작동 안되는 것을 발견했을 때, vite.config파일에서 css파트만 넣어주면 된다.
import react from '@vitejs/plugin-react';
import tailwindcss from 'tailwindcss';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
css: {
postcss: {
plugins: [tailwindcss()],
},
},
});
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
3. cdn
index.html에 cdn을 작성해도 된다 (이 방법은 라이브러리를 설치 안했을 때 사용하자)
<script src="https://cdn.tailwindcss.com"></script>
'🐡 TIL' 카테고리의 다른 글
vercel 배포 시, 새로고침 또는 특정 URL에서 404 Not Found 에러 해결 방법 (1) | 2024.06.14 |
---|---|
vscode에서 전역으로 이름 바꾸기 / 파일 내 같은 이름 교체하기 (0) | 2024.05.22 |
커밋 메시지 템플릿 설정하고, 짱편하게 커밋하기 (0) | 2024.05.01 |
[Firebase] Functions 초기 세팅 하기 (0) | 2023.07.27 |