jaredpalmer / tsdx

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

Support for .env files #1153

Open jonit-dev opened 2 years ago

jonit-dev commented 2 years 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 2 years 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;
  },
};