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

ERR_LOAD_PUBLIC_URL happens when <script src="/file-in-public.js"> exists #12643

Closed
7 tasks done
sapphi-red opened this issue Mar 29, 2023 · 2 comments · Fixed by #12650
Closed
7 tasks done

ERR_LOAD_PUBLIC_URL happens when <script src="/file-in-public.js"> exists #12643

sapphi-red opened this issue Mar 29, 2023 · 2 comments · Fixed by #12650
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@sapphi-red
Copy link
Member

sapphi-red commented Mar 29, 2023

Describe the bug

If the index.html includes <script src="/file-in-public.js"></script>, Vite outputs the following error.

Error: Failed to load url /config.js (resolved id: /config.js). 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.
    at loadAndTransform (file:///C:/Users/green/Downloads/vitejs-vite-pruyw5/node_modules/vite/dist/node/chunks/dep-f997966e.js:40835:21) {
  code: 'ERR_LOAD_PUBLIC_URL'
}

The error is output after accessing the page.

This happens in main branch (8da04227d6f818a8ad9efc0056101968037c2e36) and not with 4.3.0-beta.0.

I guess #12599 is affecting this one. /cc @bluwy

Reproduction

https://stackblitz.com/edit/vitejs-vite-pruyw5?file=main.js&terminal=dev

Steps to reproduce

No response

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 11.04 GB / 31.92 GB
  Binaries:
    Node: 18.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.15.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (111.0.1661.54)
    Internet Explorer: 11.0.19041.1566

Used Package Manager

npm

Logs

No response

Validations

@stackblitz
Copy link

stackblitz bot commented Mar 29, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sapphi-red sapphi-red added the p3-minor-bug An edge case that only affects very specific usage (priority) label Mar 29, 2023
@patak-dev
Copy link
Member

@bluwy let's release beta.1 after we close this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
2 participants