Skip to content

Commit

Permalink
fix: copy lightdom shims to root
Browse files Browse the repository at this point in the history
to make it easier for cdns like unpkg to work with RHDS, we copy the
lightdom css files into the root, avoiding the need to load assets from
`@rhds/elements/elements`
  • Loading branch information
bennypowers committed Jun 2, 2024
1 parent cb71745 commit 319778f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .changeset/tender-dingos-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
"@rhds/elements": patch
---
Copies lightdom CSS files into the package root, making it easier to use RHDS with CDNS like UNPKG.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ test-results.xml
rhds.min.js
*LEGAL.txt
*.tgz
# copied lightdom shims
rh-*

# e2e
test-results
Expand Down
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"elements/*/*-lightdom.css",
"elements/*/*-lightdom-shim.css",
"elements/rh-audio-player/i18n/*.json",
"rh-*/*.css",
"!elements/*/docs/**/*.{js,html,css,md}",
"!elements/*/demo/**/*.{js,html,css,md}",
"!elements/*/test/*.{spec,e2e}.{ts,d.ts}",
Expand Down Expand Up @@ -158,6 +159,16 @@
"react/**/*"
]
},
"copy-css": {
"command": "npx tsx scripts/copy-assets.ts",
"files": [
"elements/*/*.css",
"scripts/copy-assets.ts"
],
"output": [
"./*/*.css"
]
},
"bundle": {
"command": "node scripts/bundle.js",
"files": [
Expand Down
14 changes: 14 additions & 0 deletions scripts/copy-assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { cp, mkdir } from 'node:fs/promises';
import { dirname } from 'node:path';
import { glob } from 'glob';
import chalk from 'chalk'

for (const srcFile of await glob([
'elements/*/*-lightdom.css',
'elements/*/*-shim.css',
])) {
const destFile = srcFile.replace('elements/', '');
await mkdir(dirname(destFile));
await cp(srcFile, destFile);
console.log(`${chalk.blue`Copied`} ${srcFile} to ${destFile}`);
}

0 comments on commit 319778f

Please sign in to comment.