1、首先安装rollup-plugin-copy插件
npm i rollup-plugin-copy -D
2、在vite.config.js中引入使用
(1)引入
import copy from 'rollup-plugin-copy'
(2)使用,只在vite.config.js中的build配置中添加
build: {
rollupOptions: {
plugins: [
copy({
targets: [src: 'url', dest: 'url'], // 路径
hook: 'writeBundle', // 钩子,插件运行在rollup完成打包并将文件写入磁盘之前
verbose: true // 在终端进行console.log
})
]
}
}