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: empty CSS file was output when only .css?url is used #15846

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Feb 8, 2024

Description

When import u from './foo.css?url' is used and import './bar.css' is not used, an empty CSS file was output.

fixes #15843

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, especially the Pull Request Guidelines.
  • 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).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

@sapphi-red sapphi-red added bug feat: css p2-nice-to-have Not breaking anything but nice to have (priority) labels Feb 8, 2024
Copy link

stackblitz bot commented Feb 8, 2024

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

Comment on lines -721 to -723
if (!chunkCSS && !s) {
return null
}
Copy link
Member Author

Choose a reason for hiding this comment

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

If a file contains __VITE_CSS_URL__ (!s === false) and doesn't have side effect CSS imports (e.g. import './foo.css') (!chunkCSS === true), the if-else block below should not run and if (s) block should run.

@patak-dev
Copy link
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

📝 Ran ecosystem CI on 46a7199: Open

suite result latest scheduled
analogjs success success
astro success success
histoire failure failure
ladle success success
laravel failure failure
marko success success
nuxt success success
nx failure failure
previewjs success success
qwik failure failure
rakkas success success
remix failure failure
sveltekit success success
unocss success success
vike success success
vite-plugin-pwa success success
vite-plugin-react success failure
vite-plugin-react-pages success success
vite-plugin-react-swc success success
vite-plugin-svelte success success
vite-plugin-vue success failure
vite-setup-catalogue success success
vitepress success failure
vitest success success

@patak-dev patak-dev merged commit b2873ac into vitejs:main Feb 8, 2024
11 checks passed
@sapphi-red sapphi-red deleted the fix/empty-css-file-output-when-only-css-url-import branch February 9, 2024 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: css p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

when use css?url import css url,build result has empty duplicate css file
2 participants