1- import { existsSync , readFileSync } from 'node:fs'
1+ import { existsSync , readFileSync , writeFileSync } from 'node:fs'
22import { resolve } from 'node:path'
33import 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