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(css): no emit assets in html style tag (use class) (fix #5968) #6048

Closed
wants to merge 24 commits into from
Closed

fix(css): no emit assets in html style tag (use class) (fix #5968) #6048

wants to merge 24 commits into from

Conversation

poyoho
Copy link
Member

@poyoho poyoho commented Dec 10, 2021

Description

fix: #5968

Additional context

  • had the better way to use async method in the traverseHtml?
  • can closures be avoided createHTMLCSSCompiler ?

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.

@poyoho poyoho closed this Dec 10, 2021
@poyoho poyoho reopened this Dec 10, 2021
Shinigami92
Shinigami92 previously approved these changes Dec 11, 2021
@poyoho poyoho changed the title fix(css): assets in style no emit fix(css): assets in style no emit (fix: #5968) Dec 12, 2021
@poyoho poyoho changed the title fix(css): assets in style no emit (fix: #5968) fix(css): assets in style no emit (fix #5968) Dec 12, 2021
Shinigami92
Shinigami92 previously approved these changes Dec 12, 2021
@poyoho poyoho changed the title fix(css): assets in style no emit (fix #5968) fix(css): no emit assets in html style tag (fix #5968) Dec 12, 2021
@poyoho poyoho requested a review from bluwy December 12, 2021 00:38
@poyoho poyoho requested a review from bluwy December 17, 2021 08:14
@poyoho
Copy link
Member Author

poyoho commented Dec 17, 2021

oh, how to fix the test error

Shinigami92
Shinigami92 previously approved these changes Dec 17, 2021
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

I think the code could use some comments to describe each part's goal, it took me a while to understand the flow. I have one concern below, but otherwise this looks good to me. Pretty neat implementation too! I thought it would be longer.

I'd also prefer if another maintainer more experienced with this could take a look, this is my first time understanding this file 😅

PS: Feel free to add more comments where you see fit.

js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.css"`
if (classPropsNode) {
const classPropValue = classPropsNode.value!
s.remove(inlineStyle.loc.start.offset, inlineStyle.loc.end.offset)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to remove the inline style if classPropsNode is false too?

Copy link
Member Author

@poyoho poyoho Dec 17, 2021

Choose a reason for hiding this comment

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

false will overwrite the style prop to the class.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yes. Thanks for the explanation

@patak-dev
Copy link
Member

I'm also checking, LGTM too. We are going to try to discuss it in the next team meeting
I think we should add it to the 2.8 milestone (beta should be triggered soon), and maybe we should rename vite:html-inline-script-style-proxy to vite:html-inline-proxy

@poyoho
Copy link
Member Author

poyoho commented Dec 17, 2021

ok, I will comment it

@patak-dev patak-dev added this to the 2.8 milestone Dec 19, 2021
bluwy
bluwy previously approved these changes Dec 19, 2021
Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Looking good!

Shinigami92
Shinigami92 previously approved these changes Dec 19, 2021
@poyoho poyoho dismissed stale reviews from Shinigami92 and bluwy via 68d90e2 December 19, 2021 23:55
@ydcjeff
Copy link
Contributor

ydcjeff commented Dec 20, 2021

Does it PR has any difference with #6181?

@poyoho
Copy link
Member Author

poyoho commented Dec 20, 2021

yes, but I don't know how to mentioned pull request😅

@poyoho
Copy link
Member Author

poyoho commented Dec 20, 2021

Please review at the mentioned PR @patak-dev @Shinigami92 @bluwy.
I think use class to resolve inline style is not a best way.That will change CSS priority.

@bluwy
Copy link
Member

bluwy commented Dec 23, 2021

@poyoho Should we close this PR if #6181 supersedes this? It's a bit confusing to have two same PR names.

@poyoho
Copy link
Member Author

poyoho commented Dec 23, 2021

I'm not sure which way to take in the end. I'll change PR name?

@poyoho poyoho changed the title fix(css): no emit assets in html style tag (fix #5968) fix(css): no emit assets in html style tag (use class) (fix #5968) Dec 23, 2021
@poyoho poyoho closed this Dec 23, 2021
@patak-dev patak-dev removed this from the 2.8 milestone Dec 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: css 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.

Assets in <style> tags are not processed by vite build
6 participants