UNPKG

vike

Version:

(Replaces Next.js/Nuxt) 🔨 Composable framework to build advanced applications with flexibility and stability.

26 lines (25 loc) • 967 B
export { pluginServerEntryInject }; import { getMagicString } from '../../shared/getMagicString.js'; import { serverEntryVirtualId } from '@brillout/vite-plugin-server-entry/plugin'; import { pluginCommon } from './common.js'; import '../../assertEnvVite.js'; import { escapeRegex } from '../../../../utils/escapeRegex.js'; function pluginServerEntryInject(serverEntryId) { return { name: 'vike:pluginUniversalDeploy:serverEntry', apply: 'build', transform: { order: 'post', filter: { id: new RegExp(escapeRegex(serverEntryId)), }, handler(code, id) { const { magicString, getMagicStringResult } = getMagicString(code, id); // Inject Vike virtual server entry magicString.prepend(`import "${serverEntryVirtualId}";\n`); return getMagicStringResult(); }, }, ...pluginCommon, }; }