Skip to content

Commit

Permalink
Add primitives.css index file (#961)
Browse files Browse the repository at this point in the history
* add index file

Co-authored-by: Cameron Dutro <camertron@gmail.com>

* Create short-pots-look.md

---------

Co-authored-by: Cameron Dutro <camertron@gmail.com>
  • Loading branch information
langermank and camertron authored May 30, 2024
1 parent 195afb9 commit 0828682
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-pots-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/primitives": patch
---

Add `primitives.css` index file
29 changes: 29 additions & 0 deletions scripts/buildTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {ConfigGeneratorOptions, StyleDictionaryConfigGenerator} from '../sr
import type {TokenBuildInput} from '../src/types/TokenBuildInput'
import glob from 'fast-glob'
import {themes} from './themes.config'
import fs from 'fs'

/**
* getStyleDictionaryConfig
Expand Down Expand Up @@ -212,6 +213,34 @@ export const buildDesignTokens = (buildOptions: ConfigGeneratorOptions): void =>
* Copy `removed` files
* ----------------------------------- */
copyFromDir(`src/tokens/removed`, `${buildOptions.buildPath}removed`)

const excludePaths = [
(path: string) => {
return path === 'dist/css/functional/size/viewport.css'
},
(path: string) => {
return path.startsWith('dist/css/functional/themes/')
},
]

const all: string[] = []

for (const cssFile of glob.sync('dist/css/{base,functional}/**/*.css')) {
let skip = false

for (const matcher of excludePaths) {
if (matcher(cssFile)) {
skip = true
break
}
}

if (skip) continue

all.push(fs.readFileSync(cssFile, {encoding: 'utf8'}).trim())
}

fs.writeFileSync('dist/css/primitives.css', `${all.join('\n')}\n`)
}

/** -----------------------------------
Expand Down

0 comments on commit 0828682

Please sign in to comment.