Closed alexandredev3 closed 6 months ago
You can just do it by hand:
import {defineConfig} from 'tsup';
import dotenv from 'dotenv';
export default defineConfig({
entry: ['src/index.ts'],
env: dotenv.config().parsed,
});
You can just do it by hand:
import {defineConfig} from 'tsup'; import dotenv from 'dotenv'; export default defineConfig({ entry: ['src/index.ts'], env: dotenv.config().parsed, });
Yep, I ended up doing it that way
import { defineConfig } from 'tsup';
import "@dotenvx/dotenvx";
export default defineConfig({
clean: true,
target: 'es2020',
dts: true,
env: {
SUPABASE_CLIENT_URL: process.env.SUPABASE_CLIENT_URL!,
SUPABASE_CLIENT_PUBLIC_KEY: process.env.SUPABASE_CLIENT_PUBLIC_KEY!,
},
format: [
'cjs',
'esm'
]
});
$ npm run dotenvx run --env-file=.env.local -- tsup ./**/*.ts --watch
Thank you though! 🚀
Currently, the only way to tsup statically embed environment variables into the build is by adding them in the config file or using the
--env
cli flag:However, this process can become cumbersome, especially when dealing with multiple environment variables. What if we could simplify it by adding support for
.env
files similar to vitejs? This would allow users to simply pass the path of their.env
file:or
Upvote & Fund