use turborepo default structure, create a main
app to lazy load other sub apps and handle the top routing, so that the final build will be in one place only.
TBD:
to make sub apps be able to deployed separately, use https://github.com/originjs/vite-plugin-federation
- Turborepo
- React
- React Router (Lazy Loading)
- Storybook
- Vite
.
├── apps
│ ├── app1
│ ├── app2
│ ├── main
│ └── storybook
├── package.json
├── packages
│ ├── components
│ ├── eslint-config-custom
│ ├── tsconfig
│ └── ui
├── README.md
└── turbo.json
apps/app1
: sub app, handles it own sub routingapps/app2
: sub app, handles it own sub routingapps/main
: main entry, lazy load other sub apps and handles the top routingapps/storybook
: storybook, for ui checkingpackages/ui
: basic ui components, like buttons, tabs, cards, ...packages/componetns
: complex shareable components, like main layout, logout confirm dialog, ...packages/tsconfig
: common tsconfigpackages/eslint
: common eslint config
yarn
yarn dev
yarn dev --filter=app1
yarn dev --filter=app2
yarn dev --filter=main
yarn dev --filter=storybook
// or set it as npm script, like
yarn dev:app1
yarn dev:app2
yarn dev:main
yarn dev:storybook
yarn build:main
Output will be in apps/main/dist
by default
apps/main/dist
├── assets
│ ├── App.[hash].js // sub app, TODO: custom chunk name
│ ├── App.[hash].js // sub app, TODO: custom chunk name
│ ├── index.[hash].js
│ ├── index.[hash].css
│ ├── vendor.[hash].js
│ └── ...assets
├── index.html
└── ...public assets
yarn build:storybook
...