Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Babel 컴파일 시 BaseUrl 적용하기 #36

Open
gincheong opened this issue Apr 16, 2021 · 0 comments
Open

Babel 컴파일 시 BaseUrl 적용하기 #36

gincheong opened this issue Apr 16, 2021 · 0 comments

Comments

@gincheong
Copy link
Owner

npm install -D babel-plugin-module-resolver

설치하고, package.json 이나 .babelrc 에 아래 내용 추가

"plugins": [
  ["module-resolver", {
    "root": ["./src"],
    "alias": {
      "test": "./test",
      "underscore": "lodash"
    }
  }]
]

alias는 나는 안 썼지만, 웹 검색할때 있던 예제를 그대로 가져오느라..
기본적으로는 root 만 잘 지정하면, BaseUrl을 지정된다.

위처럼 적용하고 babel 컴파일하면, 소스코드에 절대경로로 입력했던 친구들이 다 상대경로로 바뀌어서 컴파일된다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant