/react-website-template

A boilerplate for new react apps with react-scripts and storybook

Primary LanguageJavaScriptMIT LicenseMIT

react-website-template

A boilerplate for new react apps with react-scripts, storybook and a decent scaffolding to get you started.

A lot of the scaffolding for this project is half implemented so it's easy to rip out or to modify to your needs. I've included a ton of code documentation on how to do just that.

Technologies used:

Environments

Storybook

Component documentation can be found at https://stagency.gitlab.io/stagency-web-app/?path=/docs/design-system-theme--foregrounds

Merge Request Environments

All merge requests in GitLab will receive a custom test environment. The GitLab UI will have a link to your environment.

Available Scripts

In the project directory, you can run:

yarn start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

yarn start-static

Runs the app in static mode which uses mock data instead of hitting a real server.

yarn test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

yarn generate

Generate new components in the src/ directory. This will create the component using the templates defined in scripts/plop-templates/. This generator will guide you through the process of generating the new component.

For more information, see https://plopjs.com/documentation/#bypassing-prompts

yarn storybook

Run the Storybook locally.

See https://storybook.js.org/

yarn analyze

Analyze and visualize the size of your app bundle size.

yarn lint

Lint all files.

yarn validate

Verify your code before pushing or releasing. This will run lint tasks, tests and ensure the app and storybook build. This is the same task that should be used on your CI environment.

yarn release

Release the app to production. This will run the tests, generate a production build, create a version tag and the deploy your code into the production environment.

See the scripts/release file to customize the release process.

yarn deploy-storybook

Build and deploy the Storybook to gh-pages.

See https://github.com/storybookjs/storybook-deployer

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

yarn clean

Clean generated files in the working directory.

Keeping up-to-date with this Boilerplate

This boilerplate will get updated to keep up with dependency upgrades. The easiest way to keep your app up-to-date with this repo's changes is to fork this repo as the starting point for your project. You can then pull in changes using Git.

However, if you're unable to fork this repo as your starting point, you can instead use the scripts/sync script which will rsync changes across to your app. It's pretty basic but it allows you copy changes over to your project where you can manually decide which updates you want.

Your project root needs to be clean before using the script:

cd react-website-template
./scripts/sync ../path/to/project/your/root

You can now commit the changes you want to keep in your project.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

yarn build fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify