Socket
Book a DemoInstallSign in
Socket

decorate-vite-plugin

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decorate-vite-plugin

Decorate Vite plugin

latest
npmnpm
Version
0.1.0
Version published
Weekly downloads
3.4K
-12.7%
Maintainers
1
Weekly downloads
 
Created
Source

decorate-vite-plugin

NPM NPM License Bundlephobia TypeScript

A utility library for decorating Vite plugins by enhancing their hook functions.

Installation

npm install decorate-vite-plugin --save-dev

Usage

This library allows you to decorate Vite plugins by adding additional functionality to their hook functions without modifying the original plugin code.

Support vite >= v3.

Basic Example

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { decorateVitePluginOption } from 'decorate-vite-plugin'

export default defineConfig({
  plugins: [
    decorateVitePluginOption(
      vue(),
      'transform',
      (originalTransform, plugin) => {
        return function (code, id) {
          console.log(`Transforming ${id}`)
          return originalTransform?.call(plugin, code, id)
        }
      },
    ),
  ],
})

API

decoratePlugin

Decorates a specific hook of a single Vite plugin.

function decoratePlugin<T extends keyof Plugin>(
  plugin: Plugin,
  hookName: T,
  decorator: (original: Plugin[T], plugin: Plugin) => Plugin[T],
): Plugin

decorateVitePluginOption

Decorates a hook across any valid Vite plugin option (single plugin, array of plugins, function, promise, etc.).

function decorateVitePluginOption<T extends keyof Plugin>(
  pluginOption: PluginOption,
  hookName: T,
  decorator: (original: Plugin[T], plugin: Plugin) => Plugin[T],
): PluginOption

Keywords

vite

FAQs

Package last updated on 24 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.