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: esbuild.charset not work with css plugin. #12993

Conversation

NicoKam
Copy link

@NicoKam NicoKam commented Apr 25, 2023

Description

Vite@4 has set the default config esbuild.charset to utf8, and in #12565 , the default configuration for plugin:css has also been set to utf8

This operation may lead to the generation of iconfont files being escaped, causing display errors in some cases. Although I can modify the esbuild.charset in vite.config.ts, it seems that the parameter is not passed to the plugin:css. I need to make it work.

Additional context

This is the effect of using iconfont(css) after Vite 4.

image


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 PR Title 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.

@stackblitz
Copy link

stackblitz bot commented Apr 25, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@NicoKam
Copy link
Author

NicoKam commented Apr 25, 2023

@patak-dev @bluwy CI progress has hung up. Need helps.

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

Would you move the code inside resolveEsbuildMinifyOptions?

@NicoKam NicoKam closed this May 8, 2023
@NicoKam NicoKam reopened this May 8, 2023
@NicoKam
Copy link
Author

NicoKam commented May 8, 2023

Would you move the code inside resolveEsbuildMinifyOptions?

@sapphi-red

Sorry, I don't intend to put this code in resolveEsbuildMinifyOptions because I just want to fix the code which the original author missed.

Additionally, charset is not part of the minify options, so I should not be retrieving properties which are not relevant to resolveEsbuildMinifyOptions.

If there are more places in the future that need to use options related to both charset and minify, I would consider creating a new function, such as resolveEsbuildOptionsForCssPlugin.

@sapphi-red
Copy link
Member

I should have put #9210 in minifyCSS function or should have put #12565 in resolveEsbuildMinifyOptions. That mistake is making the inconsistency here.

If we put charset in minifyCSS, then I think log* options should be in minifyCSS too. If we put charset in resolveEsbuildMinifyOptions, then I think log* options should be in resolveEsbuildMinifyOptions. I prefer placing charset in resolveEsbuildMinifyOptions because it'll make the diff smaller.

@NicoKam
Copy link
Author

NicoKam commented May 10, 2023

I should have put #9210 in minifyCSS function or should have put #12565 in resolveEsbuildMinifyOptions. That mistake is making the inconsistency here.

If we put charset in minifyCSS, then I think log* options should be in minifyCSS too. If we put charset in resolveEsbuildMinifyOptions, then I think log* options should be in resolveEsbuildMinifyOptions. I prefer placing charset in resolveEsbuildMinifyOptions because it'll make the diff smaller.

I understand. I was going to ask you to fix it.
But I was hoping that it would be merged soon to solve the problem in my project, so I raised a PR myself.
I still have vite@4.2.1 in my project.
I'm glad you noticed the problem, I'm going to close the PR and let you fix the code.

Maybe you can rename resolveEsbuildMinifyOptions to resolveEsbuildOptions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants