Skip to content

Commit c59deac

Browse files
committed
chore(docs): cleanup copy plugin
1 parent 8a2304a commit c59deac

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

docs/src/.vitepress/plugins/copy.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { existsSync, readFileSync } from 'node:fs'
1+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
22
import { resolve } from 'node:path'
33
import type { Plugin } from 'vite'
44

@@ -34,10 +34,11 @@ function copyFiles(emit: any) {
3434
emit({
3535
type: 'asset',
3636
fileName: pkgName,
37+
filePath,
3738
source: readFileSync(filePath, 'utf-8'),
3839
})
3940

40-
console.log(`Copied ${filePath} to ${resolve(__dirname, `../../src/public/${pkgName}`)}`)
41+
console.log(`Copied ${filePath} to ${resolve(__dirname, `../../public/${pkgName}`)}`)
4142
})
4243

4344
console.log('Copied vue-flow files')
@@ -46,10 +47,16 @@ export function copyVueFlowPlugin(): Plugin {
4647
return {
4748
name: 'copy-vue-flow',
4849
buildStart() {
49-
copyFiles((file: any) => this.emitFile(file))
50+
// use fs to copy files
51+
copyFiles((file: any) => {
52+
writeFileSync(resolve(__dirname, `../../public/${file.fileName}`), file.source)
53+
})
5054
},
5155
watchChange() {
52-
copyFiles((file: any) => this.emitFile(file))
56+
// use fs to copy files
57+
copyFiles((file: any) => {
58+
writeFileSync(resolve(__dirname, `../../public/${file.fileName}`), file.source)
59+
})
5360
},
5461
generateBundle() {
5562
copyFiles((file: any) => this.emitFile(file))

0 commit comments

Comments
 (0)