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: resolve @import of the proxied <style> #7031

Merged
merged 7 commits into from
Feb 23, 2022
Merged

Conversation

ygj6
Copy link
Member

@ygj6 ygj6 commented Feb 22, 2022

Description

fix: #6886

After #6321, <style>...</style> content will be converted to a virtual module

// <style>...</style>
if (node.tag === 'style' && node.children.length) {
const styleNode = node.children.pop() as TextNode
const filePath = id.replace(normalizePath(config.root), '')
inlineModuleIndex++
addToHTMLProxyCache(
config,
filePath,
inlineModuleIndex,
styleNode.content
)
js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.css"`
shouldRemove = true
}

... and will be processed by the css plugin. IIUC, we don't need to resolve @import from html proxy <style>.
We need to resolve public @import url from proxied <style>

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.

@ygj6 ygj6 added p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release labels Feb 22, 2022
@ygj6 ygj6 changed the title fix: avoid resolve @import from html proxy <style> fix: resolve @import of the proxied <style> Feb 22, 2022
Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. @poyoho would you help reviewing this PR?

@Niputi Niputi linked an issue Feb 22, 2022 that may be closed by this pull request
7 tasks
Copy link
Member

@poyoho poyoho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@ygj6
Copy link
Member Author

ygj6 commented Feb 23, 2022

@Niputi I tested #7042 locally with this PR and we didn't fix it.

@patak-dev patak-dev merged commit c7aad02 into vitejs:main Feb 23, 2022
poyoho added a commit to poyoho/vite that referenced this pull request Apr 28, 2022
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) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[vite:css] ENOENT: no such file or directory, stat '/resource/loading.css'
3 participants