chore(docs): cleanup copy plugin
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { existsSync, readFileSync } from 'node:fs'
|
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
||||||
import { resolve } from 'node:path'
|
import { resolve } from 'node:path'
|
||||||
import type { Plugin } from 'vite'
|
import type { Plugin } from 'vite'
|
||||||
|
|
||||||
@@ -34,10 +34,11 @@ function copyFiles(emit: any) {
|
|||||||
emit({
|
emit({
|
||||||
type: 'asset',
|
type: 'asset',
|
||||||
fileName: pkgName,
|
fileName: pkgName,
|
||||||
|
filePath,
|
||||||
source: readFileSync(filePath, 'utf-8'),
|
source: readFileSync(filePath, 'utf-8'),
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(`Copied ${filePath} to ${resolve(__dirname, `../../src/public/${pkgName}`)}`)
|
console.log(`Copied ${filePath} to ${resolve(__dirname, `../../public/${pkgName}`)}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('Copied vue-flow files')
|
console.log('Copied vue-flow files')
|
||||||
@@ -46,10 +47,16 @@ export function copyVueFlowPlugin(): Plugin {
|
|||||||
return {
|
return {
|
||||||
name: 'copy-vue-flow',
|
name: 'copy-vue-flow',
|
||||||
buildStart() {
|
buildStart() {
|
||||||
copyFiles((file: any) => this.emitFile(file))
|
// use fs to copy files
|
||||||
|
copyFiles((file: any) => {
|
||||||
|
writeFileSync(resolve(__dirname, `../../public/${file.fileName}`), file.source)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watchChange() {
|
watchChange() {
|
||||||
copyFiles((file: any) => this.emitFile(file))
|
// use fs to copy files
|
||||||
|
copyFiles((file: any) => {
|
||||||
|
writeFileSync(resolve(__dirname, `../../public/${file.fileName}`), file.source)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
generateBundle() {
|
generateBundle() {
|
||||||
copyFiles((file: any) => this.emitFile(file))
|
copyFiles((file: any) => this.emitFile(file))
|
||||||
|
|||||||
Reference in New Issue
Block a user