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.