Files
Folo/apps/desktop/plugins/vite/manifest.ts
T
DIYgodandDIYgod 8b07a9a573 chore: desktop dir (#2924)
* chore: desktop dir

* chore: desktop src and configs

* chore: auto-fix linting and formatting issues

* fix: path

* fix: path

* fix: path

* fix: path

* fix

* fix

* fix

* test

* test

* test

* test

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

---------

Co-authored-by: DIYgod <8266075+DIYgod@users.noreply.github.com>
2025-03-02 17:19:22 +08:00

34 lines
771 B
TypeScript

import fs from "node:fs"
import path from "node:path"
import type { Plugin } from "vite"
export default function manifestPlugin(): Plugin {
let config
return {
name: "manifest",
enforce: "post",
configResolved(resolvedConfig) {
config = resolvedConfig
},
generateBundle(_options, bundle) {
const outputDir = config.build.outDir
const assetsDir = path.join(outputDir, "assets")
const outputPath = path.join(assetsDir, "manifest.txt")
if (!fs.existsSync(assetsDir)) {
fs.mkdirSync(assetsDir, { recursive: true })
}
const fileStream = fs.createWriteStream(outputPath)
for (const fileName in bundle) {
fileStream.write(`${fileName}\n`)
}
fileStream.end()
},
}
}