This package can help you move some files that do not need to be packaged to the corresponding packaging directory.
# npm
npm i -D vite-plugin-copy-files
# pnpm
pnpm add -D vite-plugin-copy-files
# yarn
yarn add -D vite-plugin-copy-files
Add the following to your .vite.config.js
or .vite.config.ts
file:
import copyFiles from 'vite-plugin-copy-files'
export default {
plugins: [copyFiles({
include: [/\.(less|css|scss)$/],
exclude: [/node_modules/],
})],
}
Array
: A list of patterns or string to include.
- default:
[/\.(less|css|scss)$/]
Array
: A list of patterns or string to exclude.
- default:
[/node_modules/]
String
: The root directory to copy files from.
- default: with vite config option
root
String
: The entry directory to copy files from.
- default:
src
if you directory is not namedsrc
you need to specify the entry directory.
Function
: A custom file output path Function.(file:string)=>string