Giter Site home page Giter Site logo

env-define's Introduction

env-define

Use environment variables as compiler defines.

Adding this library to your build will turn all available environment variables into compiler defines prefixed with env.*.

You can then use them like so:

#if env.CI
  doSomethingSpecific();
#end

#if (env.NODE_ENV == "production")
  trace('seems like this is a production build');
#end

Additionally, there's a define called env.os.<platform>, where platform is the lower cased result of Sys.systemName(). Use at your own risk.

Downsides

Ideally, functionality like this would come directly from the compiler, but for the time being this library can do the trick with certain limitations:

  1. Be sure to list -lib env-define as far ahead in your build args as possible. This library uses init macros to add defines and if this happens after typing started, things can go quite horribly wrong, e.g.: HaxeFoundation/haxe#8368
  2. The defines will not be availble in macro context
  3. Depending on how many environment vars you have, you may find yourself burried in env defines. When printing haxe.macro.Context.getDefines() you'll probably want to filter out keys having the prefix.

env-define's People

Contributors

back2dos avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.