试了几个资源复制插件,不是没用就是不合适,于是便有了此插件
npm i vite-copy-plugin
import CopyPlugin from "vite-copy-plugin";
// vite 配置
export default defineConfig({
plugins: [
CopyPlugin([
// 目录复制
{from: 'src/static', to: 'dist/static'},
// 文件复制到目录(空及取vite配置的build.outDir 默认 dist)
{from: 'src/static/style.css', to: ''},
// 文件复制文件
{from: 'src/static/style.css', to: 'dist/index.css'},
])
],
});