Skip to content

Commit

Permalink
fix: use correct publicDir in ERR_LOAD_PUBLIC_URL (#14847)
Browse files Browse the repository at this point in the history
  • Loading branch information
appsforartists committed Nov 2, 2023
1 parent 385d580 commit 66caef3
Showing 1 changed file with 6 additions and 3 deletions.
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

0 comments on commit 66caef3

Please sign in to comment.