Skip to content

Commit

Permalink
fix: static css + build info (#3018)
Browse files Browse the repository at this point in the history
* fix: static css + build info

* test: write encoder tests
  • Loading branch information
segunadebayo authored Dec 7, 2024
1 parent af9715a commit fd87f3a
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/friendly-knives-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pandacss/node': patch
---

Fix issue where `staticCss` artifacts were not included in the build info json.
40 changes: 40 additions & 0 deletions packages/core/__tests__/style-encoder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,4 +737,44 @@ describe('style encoder', () => {
}
`)
})

test('static css - recipes', () => {
const ctx = createGeneratorContext()
ctx.staticCss.process({ recipes: '*' })
expect(ctx.encoder.toJSON()).toMatchInlineSnapshot(`
{
"schemaVersion": "x.x.x",
"styles": {
"atomic": [
"color]___[value:ButtonHighlight",
],
"recipes": {
"badge": [
"size]___[value:sm]___[recipe:badge",
"raised]___[value:true]___[recipe:badge",
],
"buttonStyle": [
"size]___[value:md]___[recipe:buttonStyle",
"variant]___[value:solid]___[recipe:buttonStyle",
"size]___[value:sm]___[recipe:buttonStyle",
"variant]___[value:outline]___[recipe:buttonStyle",
],
"cardStyle": [
"rounded]___[value:true]___[recipe:cardStyle",
],
"checkbox": [
"size]___[value:sm]___[recipe:checkbox",
"size]___[value:md]___[recipe:checkbox",
"size]___[value:lg]___[recipe:checkbox",
],
"textStyle": [
"size]___[value:h1]___[recipe:textStyle",
"size]___[value:h2]___[recipe:textStyle",
],
"tooltipStyle": [],
},
},
}
`)
})
})
8 changes: 6 additions & 2 deletions packages/node/src/build-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import type { PandaContext } from './create-context'

export async function buildInfo(ctx: PandaContext, outfile: string) {
const { filesWithCss, files } = ctx.parseFiles()

logger.info('cli', `Found ${colors.bold(`${filesWithCss.length}/${files.length}`)} files using Panda`)

const minify = ctx.config.minify
const { minify, staticCss } = ctx.config
logger.info('cli', `Writing ${minify ? '[min] ' : ' '}${colors.bold(outfile)}`)

if (staticCss) {
logger.info('cli', 'Adding staticCss definitions...')
ctx.staticCss.process(staticCss)
}

const output = JSON.stringify(ctx.encoder.toJSON(), null, minify ? 0 : 2)

ctx.output.ensure(outfile, process.cwd())
Expand Down

0 comments on commit fd87f3a

Please sign in to comment.