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

fix: replace server.origin in css plugin (fix #5408) #5571

Merged
merged 2 commits into from
Nov 7, 2021
Merged

fix: replace server.origin in css plugin (fix #5408) #5571

merged 2 commits into from
Nov 7, 2021

Conversation

dbohn
Copy link
Contributor

@dbohn dbohn commented Nov 6, 2021

Description

Pull Request #5104 introduced the server.origin configuration option to set a base URL for static assets.
This was implemented by checking for this option in the fileToDevUrl function of the assets plugin.
This function is used by the css plugin as well when registering CSS files as build dependencies.
This lead to incorrect added watch dependencies and broke HMR for Tailwind as described in #5408

This PR fixes this issue by adding the server origin to the already present replace call, that removed the config.base, if the server.origin option is set and should fix #5408.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Niputi
Copy link
Contributor

Niputi commented Nov 6, 2021

would be good if you are able to add a test so there won't be regression

@Shinigami92 Shinigami92 added p3-minor-bug An edge case that only affects very specific usage (priority) needs test labels Nov 6, 2021
@dbohn
Copy link
Contributor Author

dbohn commented Nov 6, 2021

I've updated the existing tailwind playground to include the server origin clause.
When doing so, the tests for this playground fail to run without the fix, but with the fix they pass.
As far as I can see, this is the best place to test for this as this is already pretty much the smallest reproduction, but if you think, there is a better way to test this, I would be happy to add this!

@patak-dev patak-dev changed the title fix: Replace server.origin in css plugin to correctly register dependency (fix #5408) fix: replace server.origin in css plugin (fix #5408) Nov 7, 2021
@patak-dev patak-dev merged commit bd8b66d into vitejs:main Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

server.origin breaks HMR (tailwind JIT)
4 participants