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): cachedPostcssConfig reused for multiple builds #3906

Merged
merged 4 commits into from
Jul 20, 2021

Conversation

y1d7ng
Copy link
Contributor

@y1d7ng y1d7ng commented Jun 22, 2021

Description

fix #3902

Additional context

const { build } = require("vite");

(async () => {
  await build({
    ....
    css: {
      postcss: PostcssConfig1
    }
  })
  await build({
    ....
    css: {
      postcss: PostcssConfig2
    }
  })
})();

PostcssConfig1is reused, PostcssConfig2is invalid. caused by cachedPostcssConfig

let cachedPostcssConfig: PostCSSConfigResult | null | undefined
async function resolvePostcssConfig(
config: ResolvedConfig
): Promise<PostCSSConfigResult | null> {
if (cachedPostcssConfig !== undefined) {
return cachedPostcssConfig
}


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
Copy link
Contributor

fwouts commented Jul 6, 2021

@OneNail do you need help to write up tests?

@patak-dev
Copy link
Member

@fwouts that would be great! It would be nice if you could PR some tests for this targeting OneNail fork so we can merge this together with them

@y1d7ng
Copy link
Contributor Author

y1d7ng commented Jul 6, 2021

@OneNail do you need help to write up tests?

@fwouts That's great, thank you very much.

@fwouts
Copy link
Contributor

fwouts commented Jul 13, 2021

FYI I've added tests in y1d7ng#1, please review when either of you have time :)

fwouts and others added 2 commits July 17, 2021 08:05
fix: add tests to demonstrate that PostCSS configs are not reused across projects
@y1d7ng
Copy link
Contributor Author

y1d7ng commented Jul 20, 2021

@fwouts helped to add the test, @patak-js @Shinigami92 please review this pr when either of you have time, thanks.

@patak-dev patak-dev merged commit 3a97644 into vitejs:main Jul 20, 2021
aleclarson pushed a commit to aleclarson/vite that referenced this pull request Nov 8, 2021
* fix(css): cachedPostcssConfig reused for multiple builds

* fix: add tests to demonstrate that PostCSS configs are not reused across projects

* fix: run everything in a single Jest test to ensure module cache isn't cleared

Co-authored-by: François Wouts <f@zenc.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSS config is reused for subsequent builds
4 participants