Skip to content

Commit

Permalink
fix(postcss): config change sometimes didnt trigger files extraction (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
astahmer authored Dec 17, 2023
1 parent 79e7abb commit 383b6d1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/odd-pumas-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pandacss/node': patch
---

Fix an issue with the postcss plugin when a config change sometimes didn't trigger files extraction
14 changes: 8 additions & 6 deletions packages/node/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class Builder {
context: PandaContext | undefined

private hasEmitted = false
private hasFilesChanged = true
private affecteds: DiffConfigResult | undefined

getConfigPath = () => {
Expand Down Expand Up @@ -62,8 +63,8 @@ export class Builder {
}

// file change
const hasFilesChanged = this.checkFilesChanged(ctx.getFiles())
if (hasFilesChanged) {
this.hasFilesChanged = this.checkFilesChanged(ctx.getFiles())
if (this.hasFilesChanged) {
ctx.project.reloadSourceFiles()
}
}
Expand Down Expand Up @@ -123,12 +124,12 @@ export class Builder {
}

extract = async () => {
const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : true
if (!this.hasFilesChanged && !hasConfigChanged) return

const ctx = this.getContextOrThrow()
const files = ctx.getFiles()

const hasConfigChanged = this.affecteds ? this.affecteds.hasConfigChanged : false
if (hasConfigChanged) return

const done = logger.time.info('Extracted in')

// limit concurrency since we might parse a lot of files
Expand Down Expand Up @@ -165,9 +166,10 @@ export class Builder {

root.removeAll()

const css = this.toString()
const newCss = optimizeCss(`
${this.initialRoot}
${this.toString()}
${css}
`)

root.append(newCss)
Expand Down

3 comments on commit 383b6d1

@vercel
Copy link

@vercel vercel bot commented on 383b6d1 Dec 17, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

panda-studio – ./

panda-app.vercel.app
panda-studio-chakra-ui.vercel.app
panda-studio-git-main-chakra-ui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 383b6d1 Dec 17, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

panda-docs – ./website

panda-docs.vercel.app
panda-docs-git-main-chakra-ui.vercel.app
panda-docs-chakra-ui.vercel.app
panda-css.com

@vercel
Copy link

@vercel vercel bot commented on 383b6d1 Dec 17, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.