jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.2k stars 505 forks source link

Support for .env files #1153

Open jonit-dev opened 1 year ago

jonit-dev commented 1 year ago

Current Behavior

It seems that tsdx doesn't have support for loading .env files. Even when adding a custom tsdx.config.js with this plugin, it loads variables as undefined.

Desired Behavior

Load .env files properly.

eliezer-souza commented 1 year ago

@jonit-dev It worked for me that way

const dotenv = require('rollup-plugin-dotenv');

module.exports = {
  rollup(config, options) {
    config.plugins.unshift(dotenv.default());

    return config;
  },
};