1
- import { existsSync , readFileSync } from 'node:fs'
1
+ import { existsSync , readFileSync , writeFileSync } from 'node:fs'
2
2
import { resolve } from 'node:path'
3
3
import type { Plugin } from 'vite'
4
4
@@ -34,10 +34,11 @@ function copyFiles(emit: any) {
34
34
emit ( {
35
35
type : 'asset' ,
36
36
fileName : pkgName ,
37
+ filePath,
37
38
source : readFileSync ( filePath , 'utf-8' ) ,
38
39
} )
39
40
40
- console . log ( `Copied ${ filePath } to ${ resolve ( __dirname , `../../src/ public/${ pkgName } ` ) } ` )
41
+ console . log ( `Copied ${ filePath } to ${ resolve ( __dirname , `../../public/${ pkgName } ` ) } ` )
41
42
} )
42
43
43
44
console . log ( 'Copied vue-flow files' )
@@ -46,10 +47,16 @@ export function copyVueFlowPlugin(): Plugin {
46
47
return {
47
48
name : 'copy-vue-flow' ,
48
49
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
+ } )
50
54
} ,
51
55
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
+ } )
53
60
} ,
54
61
generateBundle ( ) {
55
62
copyFiles ( ( file : any ) => this . emitFile ( file ) )
0 commit comments