Clear and concise description of the problem
This was already requested in #652, however the implementation was incomplete because it only support a single env file. There's no way to add multiple .env files.
I'm trying to make tsdown to read an .env file and also an optional .env.local file.
Suggested solution
Support multiple env-files
Alternative
I'm reading the files manually and injecting the values into the env config but it doesn't handle file changes when using watch mode.
import fs from "fs";
import path from "path";
import { defineConfig } from "tsdown/config";
import { parseEnv } from "util";
const DEV_ENV_FILES = [".env", ".env.local"]
.filter(fs.existsSync)
.map((filePath) => path.resolve(process.cwd(), filePath));
let env: Record<string, unknown> = {};
for (const filePath of DEV_ENV_FILES) {
if (fs.existsSync(filePath)) {
env = Object.assign(env, parseEnv(fs.readFileSync(filePath, "utf-8")));
}
}
export default defineConfig({
env,
});
Additional context
No response
Validations
Clear and concise description of the problem
This was already requested in #652, however the implementation was incomplete because it only support a single env file. There's no way to add multiple
.envfiles.I'm trying to make tsdown to read an
.envfile and also an optional.env.localfile.Suggested solution
Support multiple env-files
Alternative
I'm reading the files manually and injecting the values into the env config but it doesn't handle file changes when using watch mode.
Additional context
No response
Validations