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: add direct query to html-proxy css (fixes #8091) #8094

Merged
merged 3 commits into from May 11, 2022

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented May 10, 2022

Description

The error was happening here.

imports = parseImports(source)[0]

Adding direct query will make this condition true and vite:import-analysis will be skipped.
if (canSkipImportAnalysis(importer)) {

fixes #8091
refs #7869

Additional context

#8091 will be fixed by 1285ff5.
But this commit will drop sourcemap support because ?direct condition comes before ?html-proxy condition.

if (isDirectCSSRequest(id)) {
return css
} else {
// server only
if (options?.ssr) {
return modulesCode || `export default ${JSON.stringify(css)}`
}
if (inlined) {
return `export default ${JSON.stringify(css)}`
}
let cssContent = css
if (config.css?.devSourcemap) {
const sourcemap = this.getCombinedSourcemap()
await injectSourcesContent(sourcemap, cleanUrl(id), config.logger)
cssContent = getCodeWithSourcemap('css', css, sourcemap)
}
if (isHTMLProxy) {
return cssContent
}

I noticed sourcemap support for <link type="style" href="./foo.css"> is lacking. In most cases ./foo.css does not get transformed but it might be transformed by postcss.
I fixed this (03861eb) along fixing sourcemap support for inline style tag which I dropped at 1285ff5.


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.

@sapphi-red sapphi-red added feat: css p3-minor-bug An edge case that only affects very specific usage (priority) regression The issue only appears after a new release labels May 10, 2022
@poyoho
Copy link
Member

poyoho commented May 10, 2022

oh, we do the same thing #8095 🤦

@sapphi-red
Copy link
Member Author

Oh. And it seems we are failing the same test @import in html style tag hmr 🤣.

@patak-dev patak-dev merged commit 54a941a into vitejs:main May 11, 2022
@sapphi-red sapphi-red deleted the fix/html-proxy-direct-css branch May 11, 2022 07:55
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) regression The issue only appears after a new release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

regression: inlined css @font-face src url crashes Vite 2.9.7 and above
3 participants