ํฌ์ ์์ ์ค์ธ ํ๋ก์ ํธ๊ฐ ์๋จ์ด Nuxt.js๋ก ๊ตฌ์ฑ๋์ด ์์ด์
ํผ์ ๊ณต๋ถํด๋ณผ ๊ฒธ ํ๋ก์ ํธ create ๊ณผ์ ๋ถํฐ ๊ฐ๋จํ ๋ด์ฉ์ ์ ๋ฆฌํด๋ณด๊ณ ์ ํ๋ค.
Nuxt.js ?.?
Nuxt.js๋ Vue.js ์ ํ๋ฆฌ์ผ์ด์
์ ์ํ ํ๋ ์์ํฌ๋ก, ์๋ฒ ์ฌ์ด๋ ๋ ๋๋ง(SSR), ์ ์ ์ฌ์ดํธ ์์ฑ(SSG), ๊ทธ๋ฆฌ๊ณ ๋จ์ผ ํ์ด์ง ์ ํ๋ฆฌ์ผ์ด์
(SPA)์ ์ง์ํ๋ค.
Nuxt.js์ ํน์ง (Next.js์ ํน์ง๊ณผ ์ ์ฌ)
- ์๋ฒ ์ฌ์ด๋ ๋ ๋๋ง(SSR)
- ์ ์ ์ฌ์ดํธ ์์ฑ(SSG)
- ๊ฐ๋ ฅํ ๋ชจ๋ ์์คํ
- ์๋ ์ฝ๋ ๋ถํ
- SEO ์ต์ ํ
Nuxt.js ํ๋ก์ ํธ ์์ฑ ๋ฐฉ๋ฒ
1๋จ๊ณ: Nuxt.js ์ค์น
Nuxt.js ํ๋ก์ ํธ๋ฅผ ์์ฑํ๋ ค๋ฉด, ํฐ๋ฏธ๋์์ ๋ค์ ๋ช ๋ น์ด๋ฅผ ์คํ:
npx create-nuxt-app <project-name>
๋ช ๋ น์ด๋ฅผ ์คํํ๋ฉด ๋ช ๊ฐ์ง ์ค์ ์ ์ ํํด์ผํ๋๋ฐ
- Project name: ํ๋ก์ ํธ์ ์ด๋ฆ์ ์ ๋ ฅํ์ธ์.
- Programming language:
JavaScript
๋๋TypeScript
์ค ํ๋๋ฅผ ์ ํํ์ธ์. - Package manager:
npm
๋๋yarn
์ค ํ๋๋ฅผ ์ ํํ์ธ์. - UI framework:
None
,Bootstrap
,Vuetify
,Tailwind CSS
๋ฑ ์ํ๋ UI ํ๋ ์์ํฌ๋ฅผ ์ ํํ์ธ์. - Nuxt.js modules:
Axios
,PWA
,Content
๋ฑ ํ์ํ ๋ชจ๋์ ์ ํํ์ธ์. - Linting tools:
ESLint
,Prettier
๋ฑ ์ฝ๋ ํ์ง์ ์ ์งํ๊ธฐ ์ํ ๋๊ตฌ๋ฅผ ์ ํํ์ธ์. - Testing framework:
None
,Jest
,AVA
๋ฑ ํ ์คํธ ํ๋ ์์ํฌ๋ฅผ ์ ํํ์ธ์. - Rendering mode:
Universal (SSR/SSG)
๋๋Single Page App
์ค ํ๋๋ฅผ ์ ํํ์ธ์. - Deployment target:
Server (Node.js hosting)
๋๋Static (Static/JAMStack hosting)
์ค ํ๋๋ฅผ ์ ํํ์ธ์. - Development tools:
tsconfig.json
๋๋None
์ ์ ํํ์ธ์.
๋ผ๋ ์ ํ ์ค ๊ฐ์ฅ ๋ ธ๋ฉํ ํจํค์ง ๊ตฌ์ฑ์ ์ถ์ฒํ์๋ฉด..
๋ ธ๋ฉ ๊ฐ์ด๋
- Project name:
ํ๋ก์ ํธ ์ด๋ฆ
- Programming language:
TypeScript
- Package manager:
npm
- UI framework:
Tailwind CSS
- Nuxt.js modules:
Axios
- Linting tools:
ESLint
- Testing framework:
Jest
- Rendering mode:
Universal (SSR/SSG)
- Deployment target:
Static (Static/JAMStack hosting)
- Development tools:
tsconfig.json
์ด ์ค์ ์ ์๋ฃํ๋ฉด Nuxt.js ํ๋ก์ ํธ๊ฐ ์์ฑ๋จ.
2๋จ๊ณ: ํ๋ก์ ํธ ๊ตฌ์กฐ
ํ๋ก์ ํธ๊ฐ ์์ฑ๋๋ฉด ๋ค์๊ณผ ๊ฐ์ ๋๋ ํ ๋ฆฌ ๊ตฌ์กฐ๊ฐ ์์ฑ๋๋ค.
<project-name>/
โโโ assets/
โโโ components/
โโโ layouts/
โโโ pages/
โโโ plugins/
โโโ static/
โโโ store/
โโโ nuxt.config.js
โโโ package.json
3๋จ๊ณ: ๊ธฐ๋ณธ ํ์ด์ง ์์ฑ
pages
๋๋ ํ ๋ฆฌ์ index.vue
ํ์ผ์ ์์ฑํ๊ณ ๋ค์ ์ฝ๋๋ฅผ ์ถ๊ฐ:
<template>
<div>
<h1>Welcome to Nuxt.js!</h1>
</div>
</template>
<script>
export default {
name: 'IndexPage'
}
</script>
<style>
h1 {
color: #35495e;
font-family: 'Arial', sans-serif;
}
</style>
4๋จ๊ณ: ๊ฐ๋ฐ ์๋ฒ ์คํ
๋ค์ ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ๊ฐ๋ฐ ์๋ฒ๋ฅผ ์คํ:
npm run dev
๋ธ๋ผ์ฐ์ ๋ฅผ ์ด๊ณ http://localhost:3000
์ผ๋ก ์ด๋ํ์ฌ Nuxt.js ์ ํ๋ฆฌ์ผ์ด์
์ด ์ ์๋์ ํ๋์ง ํ์ธ.