A modern, production-ready boilerplate for building React component libraries. This project provides a complete development environment with Rollup bundling, TypeScript support, Storybook for component documentation, and comprehensive testing setup.
- ⚛️ React 19.2 - Built with the latest React version
- 📦 Rollup Bundler - Optimized ES modules output for tree-shaking
- 🔷 TypeScript - Full TypeScript support with type declarations
- 📚 Storybook 10 - Interactive component documentation and development
- 🧪 Vitest - Fast unit testing with React Testing Library
- 🎨 SCSS Support - Styling with SCSS and CSS modules
- ✅ ESLint & Prettier - Code linting and formatting
- 🎯 Stylelint - CSS/SCSS linting with BEM methodology
- 📱 Accessibility - JSX a11y plugin for accessibility best practices
react-rollup-boilerplate/
├── src/
│ ├── components/ # React components
│ │ ├── Button/ # Example Button component
│ │ │ ├── Button.tsx
│ │ │ ├── Button.scss
│ │ │ ├── Button.test.tsx
│ │ │ ├── Button.stories.tsx
│ │ │ └── index.ts
│ │ ├── Tabs/ # Example Tabs component
│ │ │ ├── Tabs.tsx
│ │ │ ├── Tab.tsx
│ │ │ ├── TabPanel.tsx
│ │ │ ├── TabsList.tsx
│ │ │ ├── context.ts
│ │ │ ├── *.scss
│ │ │ ├── Tabs.stories.tsx
│ │ │ └── index.ts
│ │ └── index.ts # Component exports
│ └── index.ts # Main library entry point
├── dist/ # Built library output
├── storybook-static/ # Built Storybook for deployment
├── rollup.config.mjs # Rollup bundler configuration
├── tsconfig.json # TypeScript configuration
├── vitest.config.ts # Vitest test configuration
├── eslint.config.js # ESLint configuration
└── .stylelintrc.cjs # Stylelint configuration
- Node.js >= 18
- Yarn package manager
git clone git@github.com:KaiHotz/react-rollup-boilerplate.git
cd react-rollup-boilerplate
yarn installDownload the .zip file, extract it, then:
cd react-rollup-boilerplate
yarn installStart the development environment with Storybook:
yarn startThis launches Storybook at http://localhost:6006, where you can:
- View and interact with your components
- Test different props and states
- Document component usage
- Create a new folder in
src/components/with your component name - Add your component files:
YourComponent.tsx- Component implementationYourComponent.scss- Component stylesYourComponent.test.tsx- Unit testsYourComponent.stories.tsx- Storybook storiesindex.ts- Component export
- Export your component from
src/components/index.ts
Refer to the Button and Tabs components as examples.
Import styles directly into your components:
import './YourComponent.scss';For CSS Modules support, refer to rollup-plugin-postcss.
SCSS and CSS are linted using Stylelint with BEM methodology:
yarn stylelint # Check styles
yarn stylelint:fix # Auto-fix style issuesCode quality is enforced via ESLint and Prettier:
yarn lint # Run all linters (ESLint, Stylelint, TypeScript)
yarn lint:fix # Auto-fix all linting issues
yarn eslint # Run ESLint only
yarn eslint:fix # Auto-fix ESLint issues
yarn check-types # Run TypeScript type checkerCustomize rules in eslint.config.js.
Testing is powered by Vitest and React Testing Library:
yarn test # Run tests in watch mode
yarn test:coverage # Run tests with coverage reportSee Button.test.tsx for example test patterns.
Build your library for production:
yarn buildOutput is generated in the dist/ folder with:
- ES modules for modern bundlers
- TypeScript type declarations
- Ensure you have an active NPM account
- Configure your
.npmrcfile - Update
publishConfig.registryinpackage.json - Run:
yarn releaseThis runs linting, tests, builds, and publishes your library.
yarn storybookyarn storybook:buildOutput is generated in storybook-static/.
Update the homepage URL in package.json, then:
yarn storybook:deployFor more information, see the Storybook documentation.
| Script | Description |
|---|---|
yarn start |
Start Storybook development server |
yarn build |
Build library to dist/ folder |
yarn test |
Run tests in watch mode |
yarn test:coverage |
Run tests with coverage report |
yarn lint |
Run all linters (ESLint, Stylelint, TypeScript) |
yarn lint:fix |
Auto-fix all linting issues |
yarn eslint |
Run ESLint only |
yarn eslint:fix |
Auto-fix ESLint issues |
yarn stylelint |
Run Stylelint only |
yarn stylelint:fix |
Auto-fix Stylelint issues |
yarn check-types |
Run TypeScript type checker |
yarn ci |
Run linting and tests (for CI/CD) |
yarn release |
Lint, test, build, and publish to NPM |
yarn storybook |
Start Storybook |
yarn storybook:build |
Build static Storybook |
yarn storybook:deploy |
Deploy Storybook to GitHub Pages |
- React 19 - UI library
- TypeScript - Type-safe JavaScript
- Rollup.js - Module bundler
- rollup-plugin-postcss - CSS/SCSS processing
- Storybook 10 - Component development environment
- Vite - Development server for Storybook
- Vitest - Unit test framework
- React Testing Library - React component testing
- jest-dom - Custom DOM matchers
- Playwright - Browser testing
- ESLint - JavaScript/TypeScript linting
- Prettier - Code formatting
- Stylelint - CSS/SCSS linting
- eslint-plugin-react - React-specific linting
- eslint-plugin-jsx-a11y - Accessibility linting
This project is licensed under the MIT License - see the LICENSE file for details.
Kai Hotz
- GitHub: @KaiHotz
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.