import { defineConfig } from 'vite'; import uni from '@dcloudio/vite-plugin-uni'; function uniH5ReadonlySlotPatch() { return { name: 'uni-h5-readonly-slot-patch', enforce: 'post', transform(code, id) { if (!id.includes('@dcloudio/uni-h5-vue') || !id.endsWith('vue.runtime.esm.js')) { return null; } if (!code.includes('const updateSlots = (instance, children, optimized) => {')) { return null; } const helper = ` const extendSlots = (slots, children) => { for (const key in children) { if (key === "_") { const descriptor = Object.getOwnPropertyDescriptor(slots, key); if (descriptor && descriptor.writable === false) { Object.defineProperty(slots, key, { value: children[key], configurable: true, enumerable: descriptor.enumerable, writable: true }); continue; } } slots[key] = children[key]; } }; `; return code .replace('const updateSlots = (instance, children, optimized) => {', `${helper}\nconst updateSlots = (instance, children, optimized) => {`) .replaceAll('extend(slots, children);', 'extendSlots(slots, children);'); }, }; } export default defineConfig({ plugins: [uni(), uniH5ReadonlySlotPatch()], build: { target: 'es2015', }, server: { proxy: { '/admin-api': { target: 'http://36.213.90.123:9500', changeOrigin: true, }, }, }, });