https://github.com/bem/webpack-feature-flags-plugin
https://github.com/bem/webpack-feature-flags-plugin
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bem/webpack-feature-flags-plugin
- Owner: bem
- Created: 2020-12-17T12:22:47.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-18T10:02:03.000Z (over 5 years ago)
- Last Synced: 2025-02-14T19:54:07.238Z (over 1 year ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 23
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# webpack-feature-flags-plugin
Webpack plugin for Feature Flags development.
### Usage
1. Add plugin in webpack config
```js
plugins: [
new FeatureFlagsWebpackPlugin([
{
value: 'FEATURE_1',
component: 'Button',
},
]),
],
```
2. Create a function that returns false by default
```ts
export function isFeatureEnabled(_feature: { value: string; component: string }): boolean {
return false
}
```
3. 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
```tsx
import React from 'react';
export const Button = () => {
if (isFeatureEnabled({ value: 'FEATURE_1', component: 'Button' })) {
return Button with new feature
}
return Regular button
}
```