npm i eruda -D
To use eruda without installing eruda as a package, edit the src in the plugin to https://cdn.jsdelivr.net/npm/eruda.
import { defineConfig } from "vite";
import type { PluginOption } from 'vite'
const injectEruda = (serve: boolean) => serve ? (<PluginOption>{
name: 'erudaInjector',
transformIndexHtml: html => ({
html,
tags: [
{
tag: 'script',
attrs: {
src: '/node_modules/eruda/eruda'
},
injectTo: 'body'
},
{
tag: 'script',
injectTo: 'body',
children: 'eruda.init()'
}
]
})
}) : [];
export default defineConfig(({ command }) =>
({ plugins: [erudaInjector(command==='serve')] })
);