File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,8 @@ export type {
1212 ServerBundlesFunction ,
1313 VitePluginConfig ,
1414} from "./vite" ;
15- export { vitePlugin , cloudflareDevProxyVitePlugin } from "./vite" ;
15+ export {
16+ vitePlugin ,
17+ cloudflareDevProxyVitePlugin ,
18+ getServerBuild ,
19+ } from "./vite" ;
Original file line number Diff line number Diff line change 1+ import type { ViteDevServer } from "vite" ;
2+ import type { ServerBuild } from "@remix-run/server-runtime" ;
3+
4+ const devServerBuild = "virtual:remix/server-build" ;
5+
6+ export async function getServerBuild (
7+ path : string ,
8+ viteDevServer ?: ViteDevServer
9+ ) : Promise < ServerBuild > {
10+ if ( viteDevServer ) {
11+ return viteDevServer . ssrLoadModule ( devServerBuild ) as Promise < ServerBuild > ;
12+ }
13+ try {
14+ return import ( path ) ;
15+ } catch ( error ) {
16+ console . error (
17+ `Could not find server build at '${ path } '. Did you forget to run 'remix vite:build' first?`
18+ ) ;
19+ throw error ;
20+ }
21+ }
Original file line number Diff line number Diff line change 11// This file allows us to dynamically require the plugin so non-Vite consumers
22// don't need to have Vite installed as a peer dependency. Only types should
33// be imported at the top level, or code that doesn't import Vite.
4+
45import type { RemixVitePlugin } from "./plugin" ;
56export type {
67 BuildManifest ,
@@ -15,4 +16,5 @@ export const vitePlugin: RemixVitePlugin = (...args) => {
1516 return remixVitePlugin ( ...args ) ;
1617} ;
1718
19+ export { getServerBuild } from "./get-server-build" ;
1820export { cloudflareDevProxyVitePlugin } from "./cloudflare-proxy-plugin" ;
You can’t perform that action at this time.
0 commit comments