Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

fix(vite): handle emitted assets with relative urls and dynamic base#2851

Merged
pi0 merged 2 commits intomainfrom
fix/nuxt-base
Jan 24, 2022
Merged

fix(vite): handle emitted assets with relative urls and dynamic base#2851
pi0 merged 2 commits intomainfrom
fix/nuxt-base

Conversation

@danielroe
Copy link
Copy Markdown
Member

🔗 Linked issue

resolves nuxt/nuxt#13250

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

This PR handles two issues with the recently merged support for dynamic base URLs in Vite.

  1. CSS assets are rewritten to use relative imports
  2. required assets are rewritten dynamically (we can't replace in transform because of the __VITE_ASSET map that is used by vite asset plugin).

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@danielroe danielroe added bug Something isn't working vite 🔥 p5-urgent Priority 5: build-breaking bugs that affect most users and should be fixed ASAP labels Jan 21, 2022
@danielroe danielroe requested a review from pi0 January 21, 2022 11:30
@danielroe danielroe self-assigned this Jan 21, 2022
@netlify
Copy link
Copy Markdown

netlify bot commented Jan 21, 2022

✔️ Deploy Preview for nuxt3-docs canceled.

🔨 Explore the source changes: f5131b6

🔍 Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/61ea9aaacb6e480008c7ed54

Comment thread packages/vite/src/plugins/dynamic-base.ts
@danielroe
Copy link
Copy Markdown
Member Author

This also implements this suggestion: #2655 (comment) 😁

@pi0 pi0 merged commit b803fdb into main Jan 24, 2022
@pi0 pi0 deleted the fix/nuxt-base branch January 24, 2022 12:57
@eMeRiKa13
Copy link
Copy Markdown

It didn't fixed the problem for me.

In production I now have /_nuxt/image.png, but I should have /_nuxt/assets/image.png

@danielroe
Copy link
Copy Markdown
Member Author

@eMeRiKa13 Would you raise a new issue with a reproduction please?

@eMeRiKa13
Copy link
Copy Markdown

@danielroe I tried to use the code sandbox template but I'm too beginner for that... and can't make it work.

@danielroe
Copy link
Copy Markdown
Member Author

@eMeRiKa13 If you can recreate it locally with a new nuxt project, and push that to GitHub, that would be just as good 👍

@eMeRiKa13
Copy link
Copy Markdown

@danielroe locally it works, I have /_nuxt/assets/image.png but on my Vercel deployment I only have /_nuxt/image.png

@danielroe
Copy link
Copy Markdown
Member Author

@eMeRiKa13 If you raise an issue with code I can look into it.

@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x bug Something isn't working 🔥 p5-urgent Priority 5: build-breaking bugs that affect most users and should be fixed ASAP vite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assets in css include '__NUXT_BASE__' prefix in production build

3 participants