Skip to content
This repository has been 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
merged 2 commits into from
Jan 24, 2022

Conversation

danielroe
Copy link
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

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

@danielroe
Copy link
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

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
Member Author

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

@eMeRiKa13
Copy link

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

Copy link
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

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

@danielroe
Copy link
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