Environment Variables TypeScript

前端 未结 2 1111
遇见更好的自我
遇见更好的自我 2021-01-17 08:03

let\'s say I have a block of code that I\'d like to only be present (or run) in a staging environment. I\'ve set an environment variable in that enivronment (say, ENV = \'st

2条回答
  •  太阳男子
    2021-01-17 08:56

    is there a way for TypeScript to access that variable during compilation

    Yup. Prefer using process.env that works as is in node and can be used with webpack using --define.

    More

    Example showing how to use it for build output toggles : https://basarat.gitbooks.io/typescript/content/docs/tips/build-toggles.html

提交回复
热议问题