Last active
July 2, 2021 02:14
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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