Skip to content

Instantly share code, notes, and snippets.

@prokizzle
Last active May 9, 2020 05:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save prokizzle/4d9ad745d4b9f1b5d5b5ca660240fd4e to your computer and use it in GitHub Desktop.
Feature Flags
const { filter, test, keys, fromPairs, map, match } = require('ramda');
const env = dotenv.config({ path: ".env.local" }).parsed;
const featureKeys = filter(test(/^FEATURE/), keys(env));
const FeatureFlags = fromPairs(map(key => [match(/FEATURE_([\w\W]+)/, key)[1], env[key]], featureKeys));
module.exports = {plugins: [new webpack.DefinePlugin({ ...env, FeatureFlags })]};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment