我刚刚从 webpack 转移过来copyWebpackPlugin
,并且无法理解如何调试这个插件的代码。
这是我的vite.config.ts
import { defineConfig } from 'vite';
import preact from '@preact/preset-vite';
import ssr from 'vike/plugin';
import { viteStaticCopy } from 'vite-plugin-static-copy'
export default defineConfig({
plugins: [
preact(),
ssr({ prerender: true }),
viteStaticCopy({
targets: [
{
src: 'public/assets/icons/favicon.svg', // this is a placeholder string, so we have this script to be executed once
dest: `path/to/dir`,
rename: 'filename.pdf',
transform: {
encoding: 'buffer',
handler: async (_content, path) => {
console.log(1)
try {
const response = await fetch(URL)
const json = await response.json()
console.log(json)
return await processJson(json)
} catch (e) {
console.log(path)
console.log(e)
}
},
},
}
]
})
],
});
而在里面,包括在内,npm run dev
都没有被打印出来。我唯一看到的是console.log
viteStaticCopy
processJson
[vite-plugin-static-copy] Collected 1 items.
我怎样才能解决这个问题?