import { readFileSync } from 'node:fs' import { resolve } from 'node:path' import type { Plugin } from 'vite' const FOOD_ICON_FILES = [ 'tofu.jpg', 'spinach.jpg', 'carrot.jpg', 'fish.jpg', 'redBeanCongee.jpg', 'milkTea.jpg' ] /** * Keep endless-game food icons inside the tongji subpackage. * Importing them from Vue would make Vite emit them into the main-package assets folder. */ export function tongjiFoodAssetsPlugin(): Plugin { return { name: 'tongji-food-assets', apply: 'build', generateBundle() { FOOD_ICON_FILES.forEach((fileName) => { this.emitFile({ type: 'asset', fileName: `tongji/endless-game/assets/food/${fileName}`, source: readFileSync(resolve(process.cwd(), 'tongji/endless-game/assets/food', fileName)) }) }) } } }