mirror of
https://github.com/alex8088/electron-vite.git
synced 2026-04-30 09:54:03 +08:00
28 lines
597 B
TypeScript
28 lines
597 B
TypeScript
import { type Plugin } from 'vite'
|
|
|
|
type BuildReporterApi = {
|
|
getWatchFiles: () => string[]
|
|
}
|
|
|
|
export default function buildReporterPlugin(): Plugin<BuildReporterApi> {
|
|
const moduleIds: string[] = []
|
|
return {
|
|
name: 'vite:build-reporter',
|
|
|
|
buildEnd() {
|
|
const allModuleIds = Array.from(this.getModuleIds())
|
|
const sourceFiles = allModuleIds.filter(id => {
|
|
const info = this.getModuleInfo(id)
|
|
return info && !info.isExternal
|
|
})
|
|
moduleIds.push(...sourceFiles)
|
|
},
|
|
|
|
api: {
|
|
getWatchFiles() {
|
|
return moduleIds
|
|
}
|
|
}
|
|
}
|
|
}
|