diff --git a/README.md b/README.md index 55debed..ec61449 100644 --- a/README.md +++ b/README.md @@ -6,44 +6,46 @@ A feature flag plugin for Vite. ## How to use -1. Install the plugin. - - ```bash - pnpm add -D @virtual-live-lab/vite-plugin-feature-flags - ``` - -2. Add this plugin to `vite.config.ts`. - - ```ts - import { defineConfig } from "vite"; - import { featuresPlugin } from "vite-plugin-feature-flags"; - - export default defineConfig({ - plugins: [ - featuresPlugin({ - // your feature flags - hoge: true, - fuga: false, - }), - ], - }); - ``` - -3. Add type declaration for feature flags. - - ```ts - /// - - interface ImportMetaFeatures { - hoge: boolean; - fuga: boolean; - } - ``` - -4. Use feature flags in your code. - - ```ts - if (import.meta.features.hoge) { - console.log("hoge is enabled"); - } - ``` +1. Install the plugin. + + ```bash + pnpm add -D @virtual-live-lab/vite-plugin-feature-flags + ``` + +2. Add this plugin to `vite.config.ts`. + + ```ts + import { defineConfig } from "vite"; + import { featuresPlugin } from "vite-plugin-feature-flags"; + + export default defineConfig({ + plugins: [ + featuresPlugin({ + // your feature flags + hoge: true, + fuga: false, + }), + ], + }); + ``` + +3. Add type declaration for feature flags. + + ```ts + declare module "@virtual-live-lab/vite-plugin-feature-flags/client" { + interface ImportMetaFeatures { + hoge: boolean; + fuga: boolean; + } + } + + export {}; // Declaration merging is only available in modules. + ``` + +4. Use feature flags in your code. + + ```ts + if (import.meta.features.hoge) { + console.log("hoge is enabled"); + } + ```