Skip to content

VirtualLiveLab/vite-plugin-feature-flags

Repository files navigation

@virtual-live-lab/vite-plugin-feature-flags

npm)

A feature flag plugin for Vite.

How to use

  1. Install the plugin.

    pnpm add -D @virtual-live-lab/vite-plugin-feature-flags
  2. Add this plugin to vite.config.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.

    /// <reference types="@virtual-live-lab/vite-plugin-feature-flags/client" />
    
    interface ImportMetaFeatures {
      hoge: boolean;
      fuga: boolean;
    }
  4. Use feature flags in your code.

    if (import.meta.features.hoge) {
      console.log("hoge is enabled");
    }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published