Skip to content

Commit

Permalink
fix: url may be '/' run resolveId get real path
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed May 3, 2022
1 parent ac05f25 commit 2a764af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 1 addition & 4 deletions packages/vite/src/node/plugins/importAnalysis.ts
Expand Up @@ -167,10 +167,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
}

const { moduleGraph } = server
const importerModule = moduleGraph.getModuleById(importer)
if (!importerModule) {
return null
}
const importerModule = moduleGraph.getModuleById(importer)!

if (!imports.length) {
importerModule.isSelfAccepting = false
Expand Down
5 changes: 4 additions & 1 deletion packages/vite/src/node/server/middlewares/indexHtml.ts
Expand Up @@ -190,7 +190,10 @@ const devHtmlHook: IndexHtmlTransformHook = async (

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

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

0 comments on commit 2a764af

Please sign in to comment.