-
-
Notifications
You must be signed in to change notification settings - Fork 139
Description
Clear and concise description of the problem
Currently, tsdown allows defining compile-time environment variables through two methods: a configuration file or the --env.* <value> command-line option. However, it does not support reading environment variables from .env files yet, which makes it challenging to dynamically manage these constants. Adding this feature would enhance flexibility and streamline the workflow.
I'd be happy to help implement this feature :)
Suggested solution
-
Add Command-Line Options:
Introduce the following new command-line options:--env-file <file>: Specifies the path to the .env file to load environment variables from.--env-prefix <prefix>: Defines a prefix for environment variables (default:TSDOWN).
Additionally, allow the
envPrefixoption to be set in the configuration file. -
Integrate dotenv for Environment Variable Resolution:
During the resolution ofUserConfig, usedotenvto load environment variables from the specified .env file. Apply the prefix filter (if provided) for security to ensure only relevant variables are included.
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.