UNPKG

svelte-environment-variables

Version:

This module helps you manage environment variables in your Rollup/Webpack bundled app. Examples are of Svelte and Sapper app

13 lines (12 loc) 361 B
module.exports = ( filterPrefix = "SVELTE_APP_", targetPrefix = "process.env.", excluded = [], ) => { const FRONTEND_APP_ENV_VARS = {}; for (let key in process.env) { if (key.startsWith(filterPrefix) && !excluded.includes(key)) FRONTEND_APP_ENV_VARS[targetPrefix + key] = "'" + process.env[key] + "'"; } return FRONTEND_APP_ENV_VARS; };