0.0.6 • Published 10 months ago

vite-plugin-instrumentation v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

vite-plugin-instrumentation

Inspired from NEXT.JS Instrumentation

This plugin is useful for performing asynchronous processing at the time the server starts up or during the build process.

ex: Injecting environment variables or secrets via Secret Manager

Installation

npm install -D vite-plugin-instrumentation

Usage

// vite.config.js
import { defineConfig } from "vite";
import { instrumentationPlugin } from "vite-plugin-instrumentation";

/**
 * NOTE
 * - A function that retrieves environment variables and secrets such as those from Secret Manager
 */
const fetchEnv = async () => {
  return {
    message: "MESSAGE",
  };
};

export default defineConfig({
  plugins: [
    instrumentationPlugin([
      async () => {
        console.log("Hello World!!");
      },
      async (config) => {
        const env = await fetchEnv();

        config.define = {
          ...config.define,
          __MESSAGE__: JSON.stringify(env.message),
        };
      },
    ]),
  ],
});

More details can be found here.

0.0.6

10 months ago

0.0.5

10 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago