diff --git a/.changeset/odd-pumas-try.md b/.changeset/odd-pumas-try.md new file mode 100644 index 000000000..75d162a6d --- /dev/null +++ b/.changeset/odd-pumas-try.md @@ -0,0 +1,5 @@ +--- +'@pandacss/node': patch +--- + +Fix an issue with the postcss plugin when a config change sometimes didn't trigger files extraction diff --git a/packages/node/src/builder.ts b/packages/node/src/builder.ts index d4b619c3f..6117596c5 100644 --- a/packages/node/src/builder.ts +++ b/packages/node/src/builder.ts @@ -26,6 +26,7 @@ export class Builder { context: PandaContext | undefined private hasEmitted = false + private hasFilesChanged = true private affecteds: DiffConfigResult | undefined getConfigPath = () => { @@ -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() } } @@ -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 @@ -165,9 +166,10 @@ export class Builder { root.removeAll() + const css = this.toString() const newCss = optimizeCss(` ${this.initialRoot} - ${this.toString()} + ${css} `) root.append(newCss)