11import fs from "node:fs" ;
22import path from "node:path" ;
33import { type PluginOption , type ViteDevServer , version as viteVersion } from "vite" ;
4+ import { fileURLToPath } from "node:url" ;
45
56import { findStylesInModuleGraph } from "../server/collect-styles.ts" ;
67import { VIRTUAL_MODULES } from "./constants.ts" ;
@@ -20,12 +21,16 @@ export function manifest(start: SolidStartOptions): PluginOption {
2021 return `\0${ VIRTUAL_MODULES . clientViteManifest } ` ;
2122 if ( id === VIRTUAL_MODULES . getClientManifest )
2223 return this . resolve (
23- new URL ( "../server/manifest/client-manifest" , import . meta. url ) . pathname ,
24+ fileURLToPath ( new URL ( "../server/manifest/client-manifest" , import . meta. url ) ) ,
2425 ) ;
2526 if ( id === VIRTUAL_MODULES . getManifest ) {
2627 return this . environment . config . consumer === "client"
27- ? this . resolve ( new URL ( "../server/manifest/client-manifest" , import . meta. url ) . pathname )
28- : this . resolve ( new URL ( "../server/manifest/ssr-manifest" , import . meta. url ) . pathname ) ;
28+ ? this . resolve (
29+ fileURLToPath ( new URL ( "../server/manifest/client-manifest" , import . meta. url ) ) ,
30+ )
31+ : this . resolve (
32+ fileURLToPath ( new URL ( "../server/manifest/ssr-manifest" , import . meta. url ) ) ,
33+ ) ;
2934 }
3035 if ( id === VIRTUAL_MODULES . middleware ) {
3136 if ( start . middleware ) return await this . resolve ( start . middleware ) ;
@@ -44,28 +49,35 @@ export function manifest(start: SolidStartOptions): PluginOption {
4449 if ( ! entry ) throw new Error ( "No client entry found" ) ;
4550 let rawManifest : string | undefined ;
4651
47- const viteMajor = parseInt ( viteVersion . split ( '.' ) [ 0 ] ! , 10 ) ;
52+ const viteMajor = parseInt ( viteVersion . split ( "." ) [ 0 ] ! , 10 ) ;
4853
49- const manifestKey = Object . keys ( globalThis . START_CLIENT_BUNDLE ) . find ( k => k . endsWith ( "manifest.json" ) ) ;
54+ const manifestKey = Object . keys ( globalThis . START_CLIENT_BUNDLE ) . find ( k =>
55+ k . endsWith ( "manifest.json" ) ,
56+ ) ;
5057 if ( manifestKey && viteMajor < 8 ) {
5158 const manifestAsset = globalThis . START_CLIENT_BUNDLE [ manifestKey ] as any ;
5259 rawManifest = manifestAsset . source as string ;
5360 } else {
54- try {
55- const appRoot = ( start as any ) . appRoot || "./src" ;
56- let outDir = ".solid-start/client" ;
57- if ( devServer ?. environments ?. client ?. config ?. build ?. outDir ) {
58- outDir = devServer . environments . client . config . build . outDir ;
59- } else if ( this . environment ?. config ?. build ?. outDir && this . environment ?. config ?. consumer === "client" ) {
60- outDir = this . environment . config . build . outDir ;
61- } else if ( ( globalThis as any ) . START_CLIENT_OUT_DIR ) {
62- outDir = ( globalThis as any ) . START_CLIENT_OUT_DIR ;
63- }
64- const manifestPath = path . resolve ( appRoot , ".." , outDir , ".vite/manifest.json" ) ;
65- rawManifest = fs . readFileSync ( manifestPath , "utf-8" ) ;
66- } catch ( e ) {
67- throw new Error ( `Manifest asset not found in bundle and could not be read from disk. Keys: ${ Object . keys ( globalThis . START_CLIENT_BUNDLE ) . join ( ", " ) } . Error: ${ e } ` ) ;
68- }
61+ try {
62+ const appRoot = ( start as any ) . appRoot || "./src" ;
63+ let outDir = ".solid-start/client" ;
64+ if ( devServer ?. environments ?. client ?. config ?. build ?. outDir ) {
65+ outDir = devServer . environments . client . config . build . outDir ;
66+ } else if (
67+ this . environment ?. config ?. build ?. outDir &&
68+ this . environment ?. config ?. consumer === "client"
69+ ) {
70+ outDir = this . environment . config . build . outDir ;
71+ } else if ( ( globalThis as any ) . START_CLIENT_OUT_DIR ) {
72+ outDir = ( globalThis as any ) . START_CLIENT_OUT_DIR ;
73+ }
74+ const manifestPath = path . resolve ( appRoot , ".." , outDir , ".vite/manifest.json" ) ;
75+ rawManifest = fs . readFileSync ( manifestPath , "utf-8" ) ;
76+ } catch ( e ) {
77+ throw new Error (
78+ `Manifest asset not found in bundle and could not be read from disk. Keys: ${ Object . keys ( globalThis . START_CLIENT_BUNDLE ) . join ( ", " ) } . Error: ${ e } ` ,
79+ ) ;
80+ }
6981 }
7082
7183 if ( ! rawManifest ) {
0 commit comments