(_options, bundle)
| 105 | }, |
| 106 | }, |
| 107 | async writeBundle(_options, bundle) { |
| 108 | // Find server entry filename directly from bundle chunks. |
| 109 | // This is more reliable than the manifest when rollupOptions |
| 110 | // override output.entryFileNames. |
| 111 | for (const chunk of Object.values(bundle)) { |
| 112 | if (chunk.type === "chunk" && chunk.isEntry) { |
| 113 | serverEntryFilename = chunk.fileName; |
| 114 | break; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | const manifest = bundle[".vite/manifest.json"]; |
| 119 | |
| 120 | const staticFiles: PendingStaticFile[] = []; |
| 121 | if ( |
| 122 | manifest && manifest.type === "asset" && |
| 123 | typeof manifest.source === "string" |
| 124 | ) { |
| 125 | const json = JSON.parse(manifest.source) as Manifest; |
| 126 | |
| 127 | for (const item of Object.values(json)) { |
| 128 | if (item.assets) { |
| 129 | for (let i = 0; i < item.assets.length; i++) { |
| 130 | const id = item.assets[i]; |
| 131 | |
| 132 | staticFiles.push({ |
| 133 | filePath: path.join(serverOutDir, id), |
| 134 | hash: null, |
| 135 | pathname: getAssetPath(id), |
| 136 | immutable: true, |
| 137 | }); |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | if (item.css) { |
| 142 | for (let i = 0; i < item.css.length; i++) { |
| 143 | const id = item.css[i]; |
| 144 | |
| 145 | staticFiles.push({ |
| 146 | filePath: path.join(serverOutDir, id), |
| 147 | hash: null, |
| 148 | pathname: getAssetPath(id), |
| 149 | immutable: true, |
| 150 | }); |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | const registered = await Promise.all(staticFiles.map(async (file) => { |
| 157 | const prepared = await prepareStaticFile(file, serverOutDir); |
| 158 | const rel = path.relative(serverOutDir, file.filePath); |
| 159 | const target = path.join(clientOutDir, rel); |
| 160 | await Deno.rename(file.filePath, target); |
| 161 | |
| 162 | prepared.filePath = path.join("client", prepared.filePath); |
| 163 | |
| 164 | return `registerStaticFile(${JSON.stringify(prepared)});`; |
nothing calls this directly
no test coverage detected