Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct publicDir in ERR_LOAD_PUBLIC_URL #14847

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/vite/src/node/server/transformRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,13 @@ async function loadAndTransform(
}
if (code == null) {
const isPublicFile = checkPublicFile(url, config)
let publicDirName = path.relative(config.root, config.publicDir)
if (publicDirName[0] !== '.') publicDirName = '/' + publicDirName
const msg = isPublicFile
? `This file is in /public and will be copied as-is during build without ` +
`going through the plugin transforms, and therefore should not be ` +
`imported from source code. It can only be referenced via HTML tags.`
? `This file is in ${publicDirName} and will be copied as-is during ` +
`build without going through the plugin transforms, and therefore ` +
`should not be imported from source code. It can only be referenced ` +
`via HTML tags.`
: `Does the file exist?`
const importerMod: ModuleNode | undefined = server.moduleGraph.idToModuleMap
.get(id)
Expand Down