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: Use a separate cached PostCSS config for each CSS plugin instantiation #3985

Closed
wants to merge 4 commits into from

Conversation

fwouts
Copy link
Contributor

@fwouts fwouts commented Jun 27, 2021

Description

The PostCSS config is currently cached once for the entire lifetime of the Node process. This assumes that, for a given Node process, Vite only runs on a single project. That assumption breaks for example when using Vite's API to preview different projects, each with their own PostCSS config.

This PR moves the cachedPostcssConfig variable to the cssPlugin function scope, so that each Vite server has its own independently cached value (enabling multiple projects to run in parallel).

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.

@fwouts fwouts changed the title fix: Clear the cached PostCSS config when CSS plugin is instantiated fix: Use a separate cached PostCSS config for each CSS plugin instantiation Jun 27, 2021
@fwouts
Copy link
Contributor Author

fwouts commented Jun 28, 2021

Closing because #3906 already fixes this :)

@fwouts fwouts closed this Jun 28, 2021
@fwouts fwouts deleted the postcss-reset branch June 28, 2021 03:03
@y1d7ng
Copy link
Contributor

y1d7ng commented Jun 28, 2021

Closing because #3906 already fixes this :)

I'm sorry. I commented at first, but then I found out that my solution might have an issue when vite serve, so I deleted the comment to confirm the problem.

@fwouts
Copy link
Contributor Author

fwouts commented Jun 28, 2021

No worries at all, either way we're better off with only one PR! Feel free to use my code if that helps too.

@y1d7ng
Copy link
Contributor

y1d7ng commented Jun 28, 2021

No worries at all, either way we're better off with only one PR! Feel free to use my code if that helps too.

Thanks a lot

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