A monorepo containing Stencil web components, design tokens, and Astro Starlight documentation.
- Node.js (v18 or higher)
- pnpm (v10.7.0 or higher)
# Install dependencies
pnpm install
# Start development (builds tokens & components, starts hot reload for all packages)
pnpm devThe dev server will start:
- Design tokens watch mode (rebuilds on changes)
- Components watch mode (rebuilds on changes)
- Astro Starlight docs (http://localhost:4321)
All commands should be run from the root directory.
# Start full development environment with hot reloading
# (Builds tokens & components, then starts watch mode for all)
pnpm dev
# Fast component-only dev with Stencil's built-in HMR server
# (Faster rebuilds, but components shown in Stencil's UI, not Astro)
pnpm dev:components
# Start only docs (components must be built first)
pnpm docs:dev
# Start Storybook (legacy, use docs instead)
pnpm storybookHot Reloading Performance:
- Token changes: ~50-200ms rebuild time
- Component changes: ~1-3s rebuild time (optimized with incremental builds)
- Astro doc changes: Instant HMR
- Use
pnpm dev:componentsfor fastest component iteration (Stencil's dev server with native HMR)
# Build tokens and components only
pnpm build
# Build everything (tokens, components, and docs)
pnpm build:all
# Build specific packages
pnpm tokens:build
pnpm components:build
pnpm docs:build
# Preview production docs build
pnpm docs:preview# Run unit tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run E2E tests
pnpm test:e2e# Check code with Biome
pnpm lint
# Fix linting issues
pnpm lint:fix
# Format code
pnpm format# Generate a new component with plop
pnpm plop
# Or use Stencil's generator
pnpm generateThe plop generator will:
- Create component files (.tsx, .css, .spec.ts, .e2e.ts, .stories.tsx)
- Generate Starlight documentation (with consistent structure)
- Update package.json exports automatically
# Remove all node_modules and build artifacts
pnpm clean
# Clean and reinstall dependencies
pnpm clean:install
# Clean build artifacts and rebuild
pnpm clean:buildj26-web-components/
├── packages/
│ ├── design-tokens/ # Design tokens (CSS custom properties)
│ ├── ui-webc/ # Stencil web components
│ └── docs/ # Astro Starlight documentation
├── package.json # Root package with scripts
└── pnpm-workspace.yaml # Workspace configuration
-
Run the plop generator:
pnpm plop
-
Follow the prompts:
- Component name (e.g.,
my-button) - Component description
- Component name (e.g.,
-
The generator creates:
- Component files in
packages/ui-webc/src/components/ - Documentation in
packages/docs/src/content/docs/components/
- Component files in
-
Customize the generated files:
- Update component logic in
.tsxfile - Add styles in
.cssfile - Update documentation with real examples
- Customize API reference (props, events)
- Add variants and examples
- Update component logic in
-
Test your component:
pnpm dev
Navigate to http://localhost:4321 to see your component documentation.
All component documentation follows this structure:
- Overview - Brief description of the component
- Installation - How to install the package
- Usage - TypeScript and HTML examples
- API Reference - Properties and Events tables
- Examples - Default example with preview
- Variants - Different component variations
- Start development:
pnpm dev - Make changes to components in
packages/ui-webc/src/components/ - View changes in Astro docs at http://localhost:4321
- Add/update documentation in
packages/docs/src/content/docs/ - Test with
pnpm test - Lint with
pnpm lint:fix - Build with
pnpm buildbefore committing
npm install @scouterna/ui-webc// Import and register the components
import { defineCustomElements } from '@scouterna/ui-webc/loader';
defineCustomElements();<!-- Use components in your HTML -->
<scout-button variant="primary">Click me</scout-button>Make sure you've built the components:
pnpm components:buildBuild tokens first:
pnpm tokens:buildIf you encounter issues, try a clean rebuild:
pnpm clean:install
pnpm dev- Create a new component with
pnpm plop - Follow the existing component structure
- Update documentation with real examples
- Add tests for your component
- Run
pnpm lint:fixbefore committing - Ensure
pnpm buildsucceeds