Skip to content

Instantly share code, notes, and snippets.

@leejh3224
Last active April 9, 2021 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leejh3224/fb6382be931d3f8f99e4014cbe9025eb to your computer and use it in GitHub Desktop.
Save leejh3224/fb6382be931d3f8f99e4014cbe9025eb to your computer and use it in GitHub Desktop.
// 런타임에 특정 패키지를 바라보는 경로를 수정
function alias() {
const moduleAlias = require('module-alias')
if (process.env.STAGE !== 'local') {
return
}
// 개발자가 로컬 환경에서 실행하는 경우
const cache: any = {}
const typeorm = 'typeorm'
moduleAlias.addAlias(typeorm, () => {
if (cache[typeorm]) {
return cache[typeorm]
}
// symlink를 사용
if (fs.existsSync("path to symlinked typeorm")) {
cache[typeorm] = "path to symlinked typeorm"
} else {
cache[typeorm] = "path to original typeorm"
}
return cache[typeorm]
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment