Measures your vite plugins transform speed. Support vite >= v3
.
// vite.config.js
import smvp from 'speed-measure-vite-plugin'
export default defineConfig({
plugins: smvp([vue()]), // smvp(plugins, opts)
})
smvp(plugins, {
// Hooks to measure, defaults to ['transform']
hooks: ['transform', 'resolveId', 'load'],
// Sort function for output display, defaults to undefined
// Example: sort by time in descending order
sort: (a, b) => b - a,
// Maximum gap time to consider hook process complete (in ms)
// Used to detect when a hook batch is finished in dev mode
maxGapTimeOnce: 1000,
// maxTransformTimeOnce is deprecated, use maxGapTimeOnce instead
})
This plugin wraps your Vite plugins and measures the execution time of specified hooks. Since Vite doesn't provide direct access to lifecycle hooks for pages or the completion of hot updates in development mode, an approximate indication of the hook process completion is determined using a gap-based approach.