Install Playwright Chromium browser
mainThe build command uses Playwright to snapshot your UI. You must install the Chromium browser binary once before your first build to avoid errors.
npx playwright install chromiumrepository·main·Indexed 24 days ago
https://github.com/0xgf/boneyardA tool for generating pixel-perfect skeleton loading screens by capturing actual component layouts at build time. It provides a CLI to extract UI bones using Playwright and framework-specific <Skeleton> components for React, Vue, Svelte 5, Preact, Angular, and React Native. Features include a Vite plugin for automated capture, support for CDP to reuse browser sessions, and a configurable boneyard.config.json for managing breakpoints, output directories, and authentication.
The build command uses Playwright to snapshot your UI. You must install the Chromium browser binary once before your first build to avoid errors.
npx playwright install chromiumTo use boneyard for generating skeleton loading screens, install the core package via npm.
npm install boneyard-jsBoneyard provides framework-specific imports for the <Skeleton> component. Wrap your component in <Skeleton> and provide a name and loading state. The CLI will then extract the layout based on that name.
// React
import { Skeleton } from 'boneyard-js/react'
function BlogPage() {
const { data, isLoading } = useFetch('/api/post')
return (
<Skeleton name="blog-card" loading={isLoading}>
<BlogCard data={data} />
</Skeleton>
)
}For Vite-based projects (React, Preact, Vue, Svelte), use the boneyardPlugin to automate bone capture during development without a separate terminal.
// vite.config.ts
import { boneyardPlugin } from 'boneyard-js/vite'
export default defineConfig({
plugins: [boneyardPlugin()]
})To reuse an existing browser session (to avoid downloading Chromium or to use existing auth/cookies), launch Chrome with a remote debugging port and point the CLI to it using the --cdp flag.
# 1. Start Chrome with remote debugging
# macOS:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
# 2. CLI
npx boneyard-js build --cdp 9222Create a boneyard.config.json file in your project root to control CLI and runtime defaults. This includes breakpoints, output directories, colors, and animation settings.
{
"breakpoints": [375, 768, 1280],
"out": "./src/bones",
"color": "#e5e5e5",
"darkColor": "#2a2a2a",
"animate": "shimmer",
"shimmerColor": "#ebebeb",
"darkShimmerColor": "#333333",
"speed": "2s",
"shimmerAngle": 110
}The boneyard-js build command visits your application in a headless browser, captures all named <Skeleton> components, and writes .bones.json files and a registry file to your specified output directory. It can automatically detect your dev server if no URL is provided.
<Skeleton name="..." loading={...}>.npx boneyard-js buildimport './src/bones/registry'import { Skeleton } from 'boneyard-js/native'
<Skeleton name="blog-card" loading={isLoading}>
<BlogCard />
</Skeleton>npx boneyard-js build --native --out ./bonesimport './bones/registry'npx boneyard-js buildThe build command visits your running application at various breakpoints, captures named <Skeleton> components, and writes .bones.json files to disk. It can auto-detect your dev server or take an explicit URL.
Basic Usage:
npx boneyard-js buildnpx boneyard-js build http://localhost:3000npx boneyard-js build http://localhost:3000/blog http://localhost:3000/shopnpx boneyard-js build [url] [options]To reuse your existing Chrome cookies, authentication state, and manual certificate handling, run Chrome with remote debugging enabled and use the --cdp flag.
Start Chrome:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222google-chrome --remote-debugging-port=9222Run boneyard:
npx boneyard-js build --cdp 9222
To use the boneyard CLI to extract UI bones, you must install playwright and its Chromium browser dependency:
npm install -D playwright && npx playwright install chromiumFor SSR or advanced responsive tooling, use the layout APIs to compute bone layouts without rendering the full component.
import { computeLayout, compileDescriptor, invalidateDescriptor } from 'boneyard-js'
// Simple usage
const result = computeLayout(descriptor, 375)
// Optimized usage for multiple breakpoints
const compiled = compileDescriptor(descriptor)
const mobile = computeLayout(compiled, 375)
const tablet = computeLayout(compiled, 768)
const desktop = computeLayout(compiled, 1280)
// To force a rebuild if the descriptor is mutated
invalidateDescriptor(descriptor)Import Skeleton from boneyard-js/react. Wrap your content with the component and provide a name and a loading boolean prop. The name determines the generated .bones.json file.
import { Skeleton } from 'boneyard-js/react'
function BlogPage() {
const { data, isLoading } = useFetch('/api/post')
return (
<Skeleton name="blog-card" loading={isLoading}>
{data && <BlogCard data={data} />}
</Skeleton>
)
}