A modern monorepo setup using Yarn workspaces with TypeScript support.
-
Games Vault UI: is the components library which implements the design system of the application and is exported as a package to be used in the front-end application. It can be reused for multiple applications to define a consistent design across all the applications.
-
Games Vault Front App: Is the main consumer end application where all the features and logic of the games library is implemented, it makes use of the Games Vault UI as a dependency for use the design system and the base components available.
games-vault/
├── apps/ # Applications
│ └── GamesVaultFront # Frontend app for GamesVault libray
├── packages/ # Shared packages
│ └── GamesVaultUI/ # Shared components library for GamesVault
├── .yarn/ # Yarn v4 files
├── package.json # Root package.json with workspaces
├── tsconfig.json # TypeScript configuration
├── .eslintrc.js # ESLint configuration
├── .prettierrc # Prettier configuration
└── .yarnrc.yml # Yarn configuration
For a quick start, use these in a local environment
yarn install
yarn workspace @games-vault/gamesvault-ui build
yarn workspace @games-vault/gamevault-front-app build
yarn workspace @games-vault/gamesvault-ui storybook
yarn workspace @games-vault/gamevault-front-app dev
- Node.js >= 18.0.0
- Yarn >= 4.9.2
-
Enable Yarn v4 (if not already done):
corepack enable yarn set version 4.9.2
-
Install dependencies:
yarn install
yarn build- Build all packagesyarn dev- Start development mode for all packagesyarn test- Run tests in all packagesyarn lint- Lint all packagesyarn typecheck- Type check all packagesyarn clean- Clean build artifacts in all packagesyarn format- Format all files with Prettieryarn format:check- Check formatting
yarn workspace <workspace-name> <command>- Run command in specific workspaceyarn workspaces foreach <command>- Run command in all workspacesyarn workspaces foreach -pi <command>- Run command in parallel with interleaved output
The design system is documented using Storybook, as well as the base components of the Components Library.
For a better and complete view of the design system values, run the storybook locally and verify it http://localhost:6006/
yarn workspace @games-vault/gamesvault-ui storybook
- Colors
- Light Theme
- Dark Theme
- Typography
- Radii
- Spacing
- Full testing support of components and pages
- Create more Base components in the
@games-vault/gamesvault-uicomponents library - Improve layout of filtering
- Adding microinteractions
- Fix the Deployment of the complete project. There is a pipeline running in GitHub Actions; however, it has some issues with the base route.
mkdir packages/my-new-package
cd packages/my-new-package{
"name": "@games-vault/my-new-package",
"version": "1.0.0",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc",
"dev": "tsc --watch",
"clean": "rm -rf dist",
"typecheck": "tsc --noEmit",
"lint": "eslint src --ext .ts,.tsx"
}
}{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src"]
}mkdir apps/my-new-app
cd apps/my-new-appnpx create-next-app@latest . --typescript --tailwind --app{
"name": "@games-vault/my-new-app",
"version": "1.0.0"
}- Start development mode:
yarn dev - Make changes to any package or app
- Build everything:
yarn build - Run tests:
yarn test - Lint code:
yarn lint - Format code:
yarn format
- Use
yarn workspaceto run commands in specific workspaces - Dependencies between workspaces are automatically linked
- TypeScript path mapping is configured for easy imports
- ESLint and Prettier are configured for consistent code style
- Yarn v4 uses Node.js native modules for better performance
Create .env.local files in individual apps for environment-specific variables. The root .gitignore is configured to ignore these files.
- Create a new branch
- Make your changes
- Run
yarn lintandyarn typecheck - Run
yarn test - Format with
yarn format - Create a pull request
If you encounter Yarn-related issues:
# Clear Yarn cache
yarn cache clean
# Reinstall dependencies
rm -rf node_modules
rm yarn.lock
yarn installIf TypeScript can't find modules:
# Rebuild all packages
yarn clean
yarn buildIf ESLint complains about imports:
# Make sure all packages are built
yarn build