Skip to content

Correct why to include external plugins in a custom plugin #16278

Answered by hi-ogawa
boojum asked this question in Q&A
Discussion options

You must be logged in to vote

Your "plugin function" can return PluginOption, which can be multiple Plugins.
It would look like this in your case:

// your plugin code
import type { Plugin, PluginOption } from "vite"
import react from '@vitejs/plugin-react'

export function myPlugin(): PluginOption {
  const myActualPlugin: Plugin = {
    name: "my-actual-plugin"
  }
  return [
    react(),
    myActualPlugin,
  ];
}


// plugin user code
import { defineConfig } from "vite"
import { myPlugin } from "@my/plugin"

export default defineConfig({
  plugins: [myPlugin()]
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@s3xysteak
Comment options

Answer selected by boojum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants