refactor(additional-components): move additional components into separate pkg

This commit is contained in:
braks
2022-10-08 23:25:34 +02:00
committed by Braks
parent 8567e3733b
commit c1bcc02797
82 changed files with 934 additions and 222 deletions
+18 -9
View File
@@ -2,19 +2,28 @@ import { existsSync, readFileSync } from 'fs'
import { resolve } from 'path'
import type { Plugin } from 'vite'
const copyFile = (path: string, pkgName: string) => {
const filePath = resolve(__dirname, `${path}/${pkgName}`)
if (!existsSync(filePath)) {
throw new Error(`${pkgName} not built. ` + `Run "pnpm -w build" first.`)
}
;(this as any).emitFile({
type: 'asset',
fileName: pkgName,
source: readFileSync(filePath, 'utf-8'),
})
}
export function copyVueFlowPlugin(): Plugin {
return {
name: 'copy-vue-flow',
generateBundle() {
const filePath = resolve(__dirname, '../../node_modules/@vue-flow/core/dist/vue-flow.es.js')
if (!existsSync(filePath)) {
throw new Error(`@vue-flow/core/dist/vue-flow.es.js not built. ` + `Run "pnpm -w build" first.`)
}
this.emitFile({
type: 'asset',
fileName: 'vue-flow.es.js',
source: readFileSync(filePath, 'utf-8'),
;[
{ path: '../../node_modules/@vue-flow/core/dist/', pkgName: 'vue-flow.es.js' },
{ path: '../../node_modules/@vue-flow/additional-components/dist/', pkgName: 'additional-components.es.js' },
].forEach((pkg) => {
copyFile.call(this, pkg.path, pkg.pkgName)
})
},
}