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

Warnings at build time [x] referenced in [y] didn't resolve at build time, it will remain unchanged to be resolved at runtime #26379

Open
Predota opened this issue Mar 19, 2024 · 8 comments · May be fixed by #26551

Comments

@Predota
Copy link

Predota commented Mar 19, 2024

Environment


  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.11.1
  • CLI Version: 3.11.0
  • Nitro Version: 2.9.4
  • Package Manager: npm@10.2.3
  • Builder: -
  • User Config: devtools, css
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-mrq86l-s2dqph

Describe the bug

After upgrading to 3.11, the build log is filled with messages like:

[x] referenced in [y] didn't resolve at build time, it will remain unchanged to be resolved at runtime

This is introduced when using images from the public folder in styles.

There is two examples in my reproduction, one in main.css and one in the style tag of app.vue.

Running npm run build or npm run generate will produce the warnings when building the client and the server.

Additional context

No response

Logs

No response

Copy link

stackblitz bot commented Mar 19, 2024

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

@HigherOrderLogic
Copy link
Contributor

Changing to url('~/public/favicon.ico') does the trick.

And shouldn't it be this way to refer to local assets/public file?

@Tristan971
Copy link

Tristan971 commented Mar 20, 2024

Changing to url('~/public/favicon.ico') does the trick.

No it doesn't really do the trick. Because this results in the static file being copied as an asset.

Which means that:

  • it doesn't benefit from proper browser caching afterwards, because of the name hashing
  • gets needlessly preloaded as if it was a critical part of the application (it's a referenced asset, technically, after all)

We're having this issue with our font faces, ie this (if we add the ~/public prefix to "fix" the warning):

@font-face {
  font-display: swap;
  font-family: "Poppins";
  font-style: normal;
  font-weight: 100;
  src:
    url("/fonts/poppins/poppins-v19-100.woff2") format("woff2"),
    url("/fonts/poppins/poppins-v19-100.woff") format("woff");
}

@font-face {
  font-display: swap;
  font-family: "Poppins";
  font-style: normal;
  font-weight: 300;
  src:
    url("/fonts/poppins/poppins-v19-300.woff2") format("woff2"),
    url("/fonts/poppins/poppins-v19-300.woff") format("woff");
}

[...]

This will then end up inside the manifest and all other places where we then have to specifically remove it from. And we still lose caching.

@mkody
Copy link

mkody commented Mar 22, 2024

I'm also seeing those warnings on all my Nuxt projects where I'm referencing files in my styles.
3.11.0's release notes did mention a "reimplementation of Vite's public asset handling" with #26163

[...] this PR takes full control over public assets and bypasses the vite pipeline entirely for them.

With vite.publicDir.$resolve(val) now only returning false.

@unibeck
Copy link

unibeck commented Mar 28, 2024

I am also getting this warning at build time with:

.landing-grid {
  background: url(/topo_landing_bg.svg);
}

in 3.11.0/1 leads to

/topo_landing_bg.svg referenced in ... didn't resolve at build time, it will remain unchanged to be resolved at runtime

@danielroe danielroe self-assigned this Mar 29, 2024
@Vahagn-Zaqaryan
Copy link

Same issue here, I'm using Nuxt version 3.11.2. The issue persists for the npm run build and npm run generate.

image

@gzf6
Copy link

gzf6 commented Apr 16, 2024

Same issue. Since I have a lot of public files, too many warnings are generated during build.

@Kamsou
Copy link

Kamsou commented Apr 26, 2024

Same for me with version 3.11.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants