티스토리 뷰
https://github.com/peng-jo/react-metro
GitHub - peng-jo/react-metro
Contribute to peng-jo/react-metro development by creating an account on GitHub.
github.com
해당프로젝트에서 CRA로 만들었던 프로젝트를 간단하게 VITE로 전환 해보았다.
1. vite.config.ts 로 설정파일을 사용한다.
envPrefix: "VITE_",
-> 접두사 VITE 사용
VITE_API_BASE_URL=http://localhost:3001/metro
사용예)
fetch(
`${import.meta.env.VITE_API_BASE_URL}/${props.selectedStation}`,
requestOptions,
)
2. 엔트리 구조는 index.html -> main.tsx로 들어간다.
Entry
index.html >> <script type="module" src="/src/main.tsx"></script> >> main.tsx 호출
댓글