Skip to content

Instantly share code, notes, and snippets.

@s875515
Last active July 2, 2021 02:14
Show Gist options
  • Save s875515/b674c313f7e695b4e8736d77a893d4b6 to your computer and use it in GitHub Desktop.
Save s875515/b674c313f7e695b4e8736d77a893d4b6 to your computer and use it in GitHub Desktop.
Because of the "rollup-plugin-dotenv" isn't being update all that much, so I use "@rollup/replace" and "dotenv" in conjunction.
const replace = require('@rollup/plugin-replace');
const envKeys = () => {
const envRaw = require('dotenv').config().parsed || {};
return Object.keys(envRaw).reduce(
(envValues, envValue) => ({ ...envValues, [`process.env.${envValue}`]: JSON.stringify(envRaw[envValue]) }),
{}
);
};
formats.map(format => ({
plugins: [
...somePlugins,
replace(envKeys()),
]
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment