Unplugin Has a Free API That Most Developers Dont Know About
javascript
dev.to
Unplugin lets you write bundler plugins once and they work across Vite, Webpack, Rollup, esbuild, and Rspack. Create a Universal Plugin import { createUnplugin } from "unplugin"; const myPlugin = createUnplugin((options) => ({ name: "my-plugin", transformInclude: (id) => id.endsWith(".vue") || id.endsWith(".tsx"), transform(code, id) { // Transform code — works in ALL bundlers return code.replace(/__DEV__/g, JSON.stringify(options.dev ?? false)); }, buildStart()