How to inject environment variables into webpack?

For those who are seeing this, more context can be provided int he cf worker-types GitHub:

Using bindings

It’s recommended that you create an ambient type file for any bindings your Worker uses. Create a > file named bindings.d.ts in your src directory:

bindings.d.ts

export {}; declare global { const MY_ENV_VAR: string const MY_SECRET: string const myKVNamespace: KVNamespace }
1 Like