UNPKG

@redwoodjs/sdk

Version:

A full-stack webapp toolkit designed for TypeScript, Vite, and React Server Components

19 lines (18 loc) 703 B
// port(justinvdm, 3 Dec 2024): From https://github.com/hi-ogawa/vite-environment-examples/blob/440212b4208fc66a14d69a1bcbc7c5254b7daa91/examples/react-server/src/features/utils/plugin.ts#L37 export const virtualPlugin = (name, load) => { name = "virtual:" + name; return { name: `virtual-${name}`, resolveId(source, _importer, _options) { if (source === name || source.startsWith(`${name}?`)) { return `\0${source}`; } return; }, load(id, options) { if (id === `\0${name}` || id.startsWith(`\0${name}?`)) { return load.apply(this, [id, options]); } }, }; };