Skip to content

Commit 2a764af

Browse files
committed
fix: url may be '/' run resolveId get real path
1 parent ac05f25 commit 2a764af

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/vite/src/node/plugins/importAnalysis.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
167167
}
168168

169169
const { moduleGraph } = server
170-
const importerModule = moduleGraph.getModuleById(importer)
171-
if (!importerModule) {
172-
return null
173-
}
170+
const importerModule = moduleGraph.getModuleById(importer)!
174171

175172
if (!imports.length) {
176173
importerModule.isSelfAccepting = false

packages/vite/src/node/server/middlewares/indexHtml.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,10 @@ const devHtmlHook: IndexHtmlTransformHook = async (
190190

191191
await Promise.all(
192192
styleUrl.map(async ({ start, end, code }, index) => {
193-
const url = filename + `?html-proxy&${index}.css`
193+
// NOTE: ssr url may be '/' run resolveId to get the real path
194+
let url =
195+
(await server!.pluginContainer.resolveId(filename))?.id || filename
196+
url += `?html-proxy&${index}.css`
194197

195198
// ensure module in graph after successful load
196199
const mod = await moduleGraph.ensureEntryFromUrl(url, false)

0 commit comments

Comments
 (0)