Skip to content

bem/webpack-feature-flags-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

webpack-feature-flags-plugin

Webpack plugin for Feature Flags development.

Usage

  1. Add plugin in webpack config
  plugins: [
    new FeatureFlagsWebpackPlugin([
      {
        value: 'FEATURE_1',
        component: 'Button',
      },
    ]),
  ],
  1. Create a function that returns false by default
export function isFeatureEnabled(_feature: { value: string; component: string }): boolean {
  return false
}
  1. Add new feature in your component. The plugin checking the call isFeatureEnabled function and replaces its call to true or false, depending on the flag passed to it
import React from 'react';

export const Button = () => {
    if (isFeatureEnabled({ value: 'FEATURE_1', component: 'Button' })) {
        return <button>Button with new feature</button>
    }

    return <buttton>Regular button</button>
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published