Monorepo starter using Vite and Turborepo to create microfrontend React apps, libraries, docs, testing, tooling, and more.
Install pnpm.
We recommend an LTS version of Node.js >= 16.
To work on MyOrg web apps, from the root,
-
Run
pnpm install
-
Run
pnpm dev
Please see apps/core/.env
for a list of environment variables you can set.
To run tests for all packages with Vitest, from the root, run pnpm test
.
To run end-to-end tests for all apps with Cypress, from the root, run pnpm e2e
.
When writing tests, we have helpers available in both environments using @testing-library.
To deploy the @myorg/core
app, from the root,
-
Run
pnpm build
-
Run
pnpm --filter "@myorg/core" run preview
to preview the app.
In production, please see myorg/server
.
We use the following tools:
To create a new app, run pnpm new-app
or pnpm new-app-ts
(TypeScript).
To add a library, run pnpm new-library
or pnpm new-library-ts
(TypeScript).
The main
branch is the production code.
Each package has a branch called next-<package>
, e.g. next-shared
. This is an eternal branch with the new code for <package>
.
To create an update, branch feature/*
from next-<package>
and merge back into next-<package>
to commit your work.
UAT branches are available, and should be named uat-<package>
to provide a deployment in the staging environment.
Every time a commit is pushed up, it will have a new review app deployed.
If it is a uat-<package>
branch, it will be available at https://review.myorg.com/uat-<package>
.
All other commits will be available to preview at https://review.myorg.com/<commit-short-sha>
, where <commit-short-sha>
is the first 8 characters of the commit hash.
To add a dependency to a specific workspace, run pnpm --filter "workspace" add <package-to-add>
, e.g. pnpm --filter "@myorg/data" add d3
.
Note: Do not add dependencies to the root workspace.
Please see our Storybook to see the docs and learn about what packages you can use. You can run Storybook locally while you work on your projects with pnpm run docs
.
@myorg/core
: Our main MyOrg web app
@myorg/shell
: Our core UI and design library that extends and configures Material UI
@myorg/shared
: Shared code between all MyOrg packages
@myorg/<app>-ui
: Packages with this name format are UI libraries built for specific apps but can still be used by other apps, e.g. @myorg/dashboard-ui
was built for the Dashboard portal but may provide useful UI for your project
We handle this with the changesets
CLI tool.
A developer creates a changeset, which is just a changelog for the package being updated. Then they'll version it, and if required, release it to a registry.
- Ensure you are on a
next-<package>
branch. Mergemain
in - Run
pnpm changeset-create
to write your changelog (use spacebar to pick packages) - Run
pnpm changeset-save-prerelease <tag-suffix>
only if you want to create a specific prerelease version. For example,pnpm changeset-save-prerelease rc
creates@myorg/[email protected]
- To create the new version, run
pnpm changeset-save
- To publish the new version to the registry, run
pnpm changeset-tag-and-publish
- To instead only tag the new versions, but not publish, run
pnpm changeset-tag
- Run
git push --follow-tags
If you are facing CORS errors in development, you may want to update your API's CORS rules in that environment. If that is not an option and your package is built with Vite (e.g. @myorg/core
), please update the development server proxy rules:
In apps/core/vite.config.ts
, configure your local API URL and the target API URL in the server.proxy
object.