JCU MonoRepo Test for React Components
The following tools have been used to build this styleguide:
- LernaJS: For managing multiple packages in a single repository.
- React Styleguidist: For documentation and development environment.
- SASS: Styling for React UI Components
- Webpack: For bundling packages as libraries
This folder contains all the packages that constitute your styleguide.
Each package consists of the following directory structure.
pkg_name
|-- src
|-- index.js // Source File for the component
|-- index.scss // SASS Source File
|-- package.json // This will contain individual package information
|-- README.md // Styleguidist documentation. [Link](https://react-styleguidist.js.org/docs/documenting.html#usage-examples-and-readme-files)
|-- dist // This is generated by webpack build. The index.min.js here is the entry point for the package.
This folder consists of the files required for configuring React-Styleguidist.
Here you can place SASS modules required for theming and other commonly used styles.
This is the primary file for managing dependencies for your project. Here we have our build & development scripts.
Lerna Configuration Options
Each package is bundled using the webpack configuration in this file. If a "one file fits all" approach does not suit your use case, you can have webpack configs in each
These files can be added to the repo, if you wish to utilise Github for hosting your styleguide.
- Clone the repository
- Run
yarn install
(Note: You can use npm too) - Next you will need to run
yarn install
inside each package. - Run
yarn run styleguide
in the root. This should start react-styleguidist in your local environment.
Run the command yarn run styleguide
. This will start react-styleguidist server for development on your local machine.
Run the command yarn run publish:npm
. The command executes the following steps sequentially,
lerna bootstrap
: Install all package dependencies and link any cross-dependencieslerna exec --parallel yarn run build
: Build all react UI Components parallely. Important: Each package should have build command in their package.json. Check (JcuDateTime/package.json) This step ensures that all the packages have their built files placed in dist folders.lerna publish --skip-git --registry=https://registry.npmjs.org/
: This will prompt you for version upgrades. It will then publish the packages to NPM based on (package name)and your credentials.
Note: Once this step is done. You can commit and publish to github. Of course, you can also use lerna compeletly to manage your git workflow too.
Run yarn run styleguide:build
. This will create an index.html file and a build directory that contains the react-styleguidist JS bundle. This can be commited repository when our server is ready to host styleguide.