Skip to content

Transformer for Roblox TypeScript compiler that allows getting values of process.env as string literals

License

Notifications You must be signed in to change notification settings

easy-games/rbxts-transform-env

 
 

Repository files navigation

rbxts-transform-env

Transformer for Roblox TypeScript compiler that allows getting values of process.env as string literals

Installation

npm i rbxts-transform-env, then in your tsconfig.json:

    "compilerOptions": {
        ...
        "plugins": [
            {
                "transform": "rbxts-transform-env"
            }
        ],
    }

For example, you have a .env file in your project directory as following:

HELLO=Hello, World!
NUMBER=20

Then in the typescript code, you can do

import { $env } from "rbxts-transform-env";

function sayHello() {
    return $env("HELLO");
}

const number = $env<number>("NUMBER")

and it will compile to

local function sayHello()
    return "Hello, World!"
end

local number = 20

If you want multiple ENV files, you can use the files argument in your plugin.

About

Transformer for Roblox TypeScript compiler that allows getting values of process.env as string literals

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 55.2%
  • TypeScript 44.5%
  • Shell 0.3%