vite-plugin-cp
v6.0.3
Published
A powerful Vite plugin for copying files/directories with advanced transformation and renaming capabilities.
Maintainers
Readme
vite-plugin-cp
A powerful Vite plugin for copying files/directories with advanced transformation and renaming capabilities.
Installation
npm install vite-plugin-cp --save-devUsage
import { defineConfig } from 'vite';
import cp from 'vite-plugin-cp';
export default defineConfig({
plugins: [
cp({
targets: [
// Copy all files from 'node_modules/vite/dist' to 'dist/cp/test'
{ src: './node_modules/vite/dist', dest: 'dist/cp/test', flatten: true },
// Copy all files from 'node_modules/vite/dist' to 'dist/cp/test2', but keep the directory structure
{ src: './node_modules/vite/dist', dest: 'dist/cp/test2' },
// Copy the README.md file from 'node_modules/vite' to 'dist/cp'
{ src: './node_modules/vite/README.md', dest: 'dist/cp' },
{ src: './node_modules/vite/index.cjs', dest: 'dist/cp', rename: 'index.js' },
// Copy all .ts files from 'node_modules/vite' to 'dist/cp/types'
{ src: './node_modules/vite/**/*.ts', dest: 'dist/cp/types' },
// Copy all .ts files from 'node_modules/vite' to 'dist/cp/types2', but modify the name
{
src: './node_modules/vite/**/*.ts', dest: 'dist/cp/types2', rename(name) {
return name.replace('.d.ts', '.ts');
}
},
// Copy the package.json file from 'node_modules/vite' to 'dist/cp', but modify the name and version
{
src: './node_modules/vite/package.json', dest: 'dist/cp', transform(buf: Buffer) {
const pkg = JSON.parse(buf.toString());
return JSON.stringify({
...pkg,
name: 'vite-plugin-cp-test',
version: '1.0.0'
}, null, 2);
}
}
]
})
]
});Documentation
For detailed usage instructions and API references, please visit the official documentation:
Contributing
We welcome contributions from the community! If you find a bug or want to suggest an improvement, feel free to open an issue or submit a pull request.
How to Contribute
- Fork the repository.
- Create a new branch for your changes.
- Submit a pull request with a clear description of your changes.
License
This project is licensed under the MIT License.

