본문 바로가기
FRONTEND/Reddit 번역

디렉토리 구별 - "./file" vs "file" 의 차이점

by 또야또야 2021. 1. 8.
반응형
  • src = "images/file.png" - 현재 디렉토리에서 찾기

  • src = "./images/file.png" - 현재 디렉토리에서 찾기

  • src = "../images/file.png" - 상위 디렉토리에서 찾기

  • src = "/images/file.png" - 루트('/') 디렉토리에서 찾기

"images""./images" 의 모두 현재 디렉토리에서 찾는것이고, 지극히 개인적인 취향입니다.

그러나 번들러 bundler 또는 빌드build 프로그램을 사용하는 경우, "images"  "./images" 는 다르게 동작할 수 있습니다.

Parcel bundler 의 경우, "./images" 는 현재 디렉토리에서 상대적 위치에서 으로 취급 하지만  "node_modules" 폴더에서 파일을 찾습니다 . (JavaScript NPM 또는 Yarn을 사용하는 경우 "node_modules" 가 생성됨)

출처: www.reddit.com/r/html5/comments/kku3pp/question_hreffile_vs_file_or_vs/

 

Question href="./file" vs "/file" or ./ vs /

Hello guys, hope someone can bring me some light. When I use href , is it just source and when I use src is it ./source. This simple dot was...

www.reddit.com

 

반응형

댓글