๐Ÿš€ Vercel ๋ฐฐํฌ ํŠธ๋Ÿฌ๋ธ”์ŠˆํŒ… 1(Troubleshooting)

๋ฐ•์• ๋ฆฌยท2025๋…„ 2์›” 25์ผ

MBTI Test ํ”„๋กœ์ ํŠธ๋ฅผ ๋ฐฐํฌํ•˜๋ฉด์„œ ๊ฒช์—ˆ๋˜ ๋‹ค์–‘ํ•œ ๋ฌธ์ œ๋“ค์„ ํ•ด๊ฒฐํ•œ ๊ณผ์ •์„ ์ •๋ฆฌํ–ˆ์Šต๋‹ˆ๋‹ค.
์ฒ˜์Œ์—๋Š” ๊ธฐ๋ณธ์ ์ธ ๋ฐฐํฌ ๊ณผ์ •์„ ๋”ฐ๋ผ๊ฐ”์ง€๋งŒ, ์—ฌ๋Ÿฌ ์˜ค๋ฅ˜๋ฅผ ๋งŒ๋‚ฌ๊ณ , ์ด๋ฅผ ํ•ด๊ฒฐํ•˜๋ฉด์„œ ๋ฐฐํฌ๋ฅผ ์•ˆ์ •ํ™”์‹œ์ผฐ์Šต๋‹ˆ๋‹ค.


๐ŸŸข Vercel ๋ฐฐํฌ ๋ฌธ์ œ & ํ•ด๊ฒฐ ๊ณผ์ •

1๏ธโƒฃ ์ดˆ๊ธฐ ๋ฐฐํฌ ์‹œ๋„ (vercel build ์‹คํŒจ)

โš ๏ธ ๋ฌธ์ œ:

[vite]: Rollup failed to resolve import "react-router-dom"
  • vite build ๊ณผ์ •์—์„œ react-router-dom์„ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค๋Š” ์˜ค๋ฅ˜ ๋ฐœ์ƒ
  • ํ•˜์ง€๋งŒ package.json์—๋Š” ๋ถ„๋ช…ํžˆ react-router-dom์ด ์กด์žฌ

๐Ÿ” ์›์ธ ๋ถ„์„:

  • node_modules๊ฐ€ ์ œ๋Œ€๋กœ ์„ค์น˜๋˜์ง€ ์•Š์•˜์„ ๊ฐ€๋Šฅ์„ฑ์ด ์žˆ์Œ
  • react-router-dom ๋ฒ„์ „์ด ๋„ˆ๋ฌด ์ตœ์‹ ์ด๋ผ vite์—์„œ ์ •์ƒ์ ์œผ๋กœ ์ฒ˜๋ฆฌ๋˜์ง€ ์•Š์„ ์ˆ˜๋„ ์žˆ์Œ
  • Vercel์—์„œ ์บ์‹œ๊ฐ€ ๊ผฌ์—ฌ ์žˆ์–ด์„œ ์ด์ „ ์ƒํƒœ๊ฐ€ ๋‚จ์•„ ์žˆ์„ ์ˆ˜๋„ ์žˆ์Œ

โœ… ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•:
1๏ธโƒฃ ํŒจํ‚ค์ง€ ์žฌ์„ค์น˜

rm -rf node_modules package-lock.json yarn.lock
yarn install

2๏ธโƒฃ react-router-dom์„ ์•ˆ์ •์ ์ธ ๋ฒ„์ „(6.4.0)์œผ๋กœ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œ

yarn add react-router-dom@6.4.0

3๏ธโƒฃ Vercel ๋นŒ๋“œ ์บ์‹œ ์‚ญ์ œ ํ›„ ๋‹ค์‹œ ๋ฐฐํฌ

vercel --force

โžก๏ธ ์ด๋ ‡๊ฒŒ ์ ์šฉํ•œ ํ›„, vercel build๊ฐ€ ์ •์ƒ์ ์œผ๋กœ ์ง„ํ–‰๋จ


2๏ธโƒฃ vite build ์‹œ Tailwind CSS Nesting ์˜ค๋ฅ˜

โš ๏ธ ๋ฌธ์ œ:

[vite:css][postcss] Nested CSS was detected, but CSS nesting has not been configured correctly.
  • Tailwind CSS์˜ Nesting์ด ์„ค์ •๋˜์ง€ ์•Š์Œ

โœ… ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•:
1๏ธโƒฃ tailwind.config.js์— Nesting ์„ค์ • ์ถ”๊ฐ€

module.exports = {
  plugins: [require('tailwindcss/nesting')],
};

2๏ธโƒฃ PostCSS์—๋„ Nesting ์ง€์› ์ถ”๊ฐ€ (postcss.config.js)

module.exports = {
  plugins: {
    'postcss-nested': {},
    tailwindcss: {},
    autoprefixer: {},
  },
};

โžก๏ธ ๋‹ค์‹œ vercel build ์‹คํ–‰ โ†’ ์ •์ƒ์ ์œผ๋กœ ๋นŒ๋“œ๋จ ๐ŸŽ‰


3๏ธโƒฃ vercel.json ๋ฏธ์„ค์ • ๋ฌธ์ œ

โš ๏ธ ๋ฌธ์ œ:

  • Vercel์—์„œ vite.config.js๋ฅผ ์ œ๋Œ€๋กœ ์ธ์‹ํ•˜์ง€ ๋ชปํ•ด ๋ฐฐํฌ ํ›„ 404 ์˜ค๋ฅ˜ ๋ฐœ์ƒ
  • index.html์„ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค๋Š” ์˜ค๋ฅ˜ ๋ฐœ์ƒ

โœ… ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•:
1๏ธโƒฃ vercel.json ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  vite ์„ค์ • ์ถ”๊ฐ€

{
  "build": {
    "env": {
      "NODE_ENV": "production"
    },
    "command": "vite build",
    "outputDirectory": "dist"
  },
  "rewrites": [
    { "source": "/(.*)", "destination": "/index.html" }
  ]
}

2๏ธโƒฃ ๋‹ค์‹œ ๋ฐฐํฌ

vercel deploy

โžก๏ธ ๋ฐฐํฌ ํ›„ ์ •์ƒ์ ์œผ๋กœ ๋ผ์šฐํŒ…๋จ! โœ…


๐ŸŽฏ ์ตœ์ข… ์ •๋ฆฌ

โœ… Vercel ๋ฐฐํฌ ํŠธ๋Ÿฌ๋ธ”์ŠˆํŒ…

  1. ํŒจํ‚ค์ง€ ์บ์‹œ ์‚ญ์ œ ํ›„ ์žฌ์„ค์น˜ (yarn install)
  2. react-router-dom ๋ฒ„์ „ ๋‹ค์šด๊ทธ๋ ˆ์ด๋“œ (6.4.0)
  3. Tailwind CSS Nesting ์„ค์ • (tailwind.config.js, postcss.config.js ์ˆ˜์ •)
  4. vercel.json ์„ค์ • ์ถ”๊ฐ€ (๋นŒ๋“œ ๋ช…๋ น์–ด & ๋ผ์šฐํŒ… ์„ค์ •)
  5. vercel --force๋กœ ์บ์‹œ ์—†์ด ๋ฐฐํฌ ์ง„ํ–‰

0๊ฐœ์˜ ๋Œ“๊ธ€