Skip to content

Instantly share code, notes, and snippets.

@prokizzle
Last active May 9, 2020 05:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prokizzle/4d9ad745d4b9f1b5d5b5ca660240fd4e to your computer and use it in GitHub Desktop.
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