-
-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using import.meta.env fails inside of a trigger.dev build #1333
Comments
Hacky solution:
Then update your trigger.config.ts file like so: import { defineConfig } from "@trigger.dev/sdk/v3";
import { esbuildPlugin } from "@trigger.dev/build";
import { esbuild as importMetaEnvPlugin } from "@import-meta-env/unplugin";
export default defineConfig({
project: "<your project ref>",
build: {
extensions: [
esbuildPlugin(
importMetaEnvPlugin({
example: ".env.example",
env: ".env",
}) as any
),
],
},
});
(globalThis as any).import_meta_env = process.env; |
Did you test this solution? I'm not able to get it to recognize the
I tried messing around with the plugin's Library versions:
|
You can actually transpile all the envs at the build time using this option: importMetaEnvPlugin({
env: './.env',
example: './.env.example',
transformMode: 'compile-time',
}) So you don't have to add the last line to expose it again.
|
From what I can tell,
import.meta.env
is a vite thing that populatesimport.meta.env
with environment variables.https://import-meta-env.org/guide/getting-started/introduction.html
An example usage is here:
https://github.com/usetonearm/core-web/blob/d178a6277306e9bfe0cde49c6550ceae33475292/packages/supabase/src/get-supabase-client-keys.ts#L6
They do have an esbuild plugin that we should look into seeing if it solves the issue.
The text was updated successfully, but these errors were encountered: