반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- e2e
- devtools
- CSS
- Cypress
- caching
- 비동기
- TLS
- custom command
- Testing
- SSR
- typeScript
- 선택자
- csr
- msw
- ts error
- vue3
- https
- vue
- rendering
- web vital
- svelte
- api test
- QUIC
- CloudFlare
- ViTE
- vue-cli
- import.meta.env
- http3
- JavaScript
- aws
Archives
- Today
- Total
Develop Note by J.S.
[Vite] Vite + Vue3 + Typescript 본문
반응형
Vite Tool을 이용하여 Vue3 + Typescript 프로젝트 생성 및 초기 Config File에 대한 설명 입니다.
1. vue 프로젝트 생성
$npm init vue@latest

프로젝트에서 사용할 기능들을 체크하여 생성합니다. 테스트는 Typescript, Vue Router, Pinia, ESLint, Prettier를 선택하여 프로젝트를 생성하였습니다.
모듈 설치
$npm install
DevServer 실행
$npm run dev
Build
$npm run build
2. Vite.config.ts
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
build: {
rollupOptions: {
input: { //entry 경로, multi page 개발 시 지정
main: resolve(__dirname, 'index.html'),
},
output: { //build output 설정
assetFileNames: (assetInfo: any) => {
let extType = assetInfo.name.split('.').at(1);
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType)) {
extType = 'img';
}
return `assets/${extType}/[name]-[hash][extname]`;
},
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
},
},
},
})
alias는 value에 있는 ./src 의 경로를 소스 내에서 '@' 키워드로 치환하여 사용하겠다는 설정입니다.
3. tsconfig.json
현재 Vite@4.3.9 버전에서는 tsconfig 파일이 아래와 같이 app 환경과 node 환경의 tsconfig 파일이 생성됩니다.

tsconfig.app.json의 경우 ./src하위 app 영역의 tsconfig 설정이며, node는 Vite를 포함한 config 설정에 관한 컴퓨터 내부 Node영역에서 구동하는 ts설정입니다.
반응형
'FrontEnd > Vite&Vue-cli' 카테고리의 다른 글
[Vue-cli] 다중 페이지 (Vue Multi-Instance) (0) | 2023.07.28 |
---|---|
[Vite] SourceMap (0) | 2023.07.27 |
[Vite] process.env vs import.meta.env & Migration (0) | 2023.07.12 |
[Vite] Vite 환경변수 활용 (0) | 2023.07.05 |
[Vite] Vite란 (0) | 2023.07.04 |