Vite plugin for copying files/directories during builds with advanced transformation and renaming. Supports glob patterns, flattening, rename functions, and transform buffers. Integrates with Vite's build pipeline. v6.0.3 requires Vite >=3.1.0 and Node >=14.18.0. Ships TypeScript types. Alternative to rollup-plugin-copy with Vite-native hooks and simpler API.
npm install vite-plugin-cpVerified import paths — ran on the pinned version, not inferred.
Configures vite-plugin-cp with three copy targets: a glob flatten copy, a single file rename, and a JSON transform that adds a build date.
Migrate to targets array with src/dest pairs.
Use default import: import cp from 'vite-plugin-cp'.
Remove the 'watch' option from plugin config.
Ensure transform function always returns a Buffer or string.
Prefix globs with './' and ensure they match from project root.
Use 'rename' to avoid conflicts or avoid flattening.
Run 'npm install vite-plugin-cp --save-dev'.
Change to 'import cp from 'vite-plugin-cp''
Ensure each target object has both 'src' and 'dest' properties.
Verify that the source path is correct and exists relative to project root.
Ensure transform returns a Buffer or string, e.g., return Buffer.from('...').