A Vite plugin that enables importing CSV files directly into JavaScript/TypeScript code, returning parsed JSON arrays. Version 1.0.0 stable. It works with Vite 2.x and above, supports any framework (React, Vue, Svelte, etc.), and ships TypeScript declarations. Unlike manual CSV parsing, it integrates seamlessly with Vite's import system and hot module replacement.
npm install vite-plugin-csvVerified import paths — ran on the pinned version, not inferred.
Shows how to install, configure the plugin in vite.config.js, and import a CSV file.
Add a declaration file with `declare module '*.csv' {}` to your project.Upgrade Vite to ^2.0.0 or later.
Consider splitting large CSVs or using a runtime parser for dynamic data.
Do not import CSV files with sensitive data; load them via fetch at runtime instead.
Create a .d.ts file with `declare module '*.csv' { const data: any; export default data; }`Use `import CSV from 'vite-plugin-csv'` instead of `import { CSV } from 'vite-plugin-csv'`.