
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
vite-audit-plugin
Advanced tools
It records detailed timings, file modifications, and plugin executions, outputting structured logs (JSON/CLI) to help optimize and troubleshoot Vite projects.
vite-audit-plugin 📊🔍A comprehensive auditing plugin for Vite projects that analyzes your application during development and build processes, providing actionable insights for performance, security, and best practices.
npm install vite-audit-plugin --save-dev
# or
yarn add vite-audit-plugin -D
# or
pnpm add vite-audit-plugin -D
Add the plugin to your vite.config.js/vite.config.ts:
import { defineConfig } from 'vite'
import viteAudit from 'vite-audit-plugin'
export default defineConfig({
plugins: [
viteAudit({
// Plugin options (all optional)
bundleAnalysis: true, // Enable bundle analysis
securityCheck: true, // Check for vulnerable dependencies
performanceMetrics: true, // Collect performance metrics
bestPractices: true, // Validate best practices
outputFile: 'audit-report.html', // Output file name
performanceBudget: { // Set performance budgets
'*.js': '500KB',
'*.css': '100KB',
'*.png': '100KB'
}
})
]
})
| Option | Type | Default | Description |
|---|---|---|---|
bundleAnalysis | boolean | true | Enable bundle size analysis |
securityCheck | boolean | true | Check for vulnerable dependencies |
performanceMetrics | boolean | true | Collect performance metrics |
bestPractices | boolean | true | Validate against best practices |
outputFile | string | 'audit-report.html' | Output file path |
performanceBudget | object | undefined | Key-value pairs of file patterns and size limits |
failOnError | boolean | false | Fail build when audits don't pass |
verbose | boolean | false | Show detailed audit information in console |
After building your project, you'll find an audit report (default: audit-report.html) with sections like:
Bundle Analysis
Security Audit
Performance Metrics
Best Practices
Set size limits for different file types to prevent performance regressions:
viteAudit({
performanceBudget: {
'*.js': '300KB',
'*.css': '50KB',
'*.jpg': '100KB',
'total': '1MB'
}
})
If budgets are exceeded, the plugin will warn you or fail the build (if failOnError is true).
For CI environments, use the CLI output format:
viteAudit({
outputFile: 'audit-report.json',
verbose: true
})
Then in your CI script:
vite build && cat audit-report.json | jq '.metrics'
Extend the default audits with your own:
viteAudit({
customAudits: [
{
name: 'My Custom Audit',
run: async () => {
return {
score: 0.9,
details: { /* your audit results */ }
}
}
}
]
})
Use the plugin's API directly:
import { runAudits } from 'vite-audit-plugin';
const results = await runAudits({
dir: './dist',
audits: ['bundle', 'security']
});
console.log(results);
Issue: Plugin fails with "Cannot find module"
Issue: Security audit takes too long
viteAudit({
securityCheck: process.env.NODE_ENV === 'production'
})
FAQs
It records detailed timings, file modifications, and plugin executions, outputting structured logs (JSON/CLI) to help optimize and troubleshoot Vite projects.
The npm package vite-audit-plugin receives a total of 0 weekly downloads. As such, vite-audit-plugin popularity was classified as not popular.
We found that vite-audit-plugin demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.