policy-design-lab / pdl-frontend

1 stars 0 forks source link

React Template

A template for React web applications

This template is configured with the latest LTS version of Node (v14).

Bundling (webpack):

Use npm start to start the dev server.

Use npm run build to create production build.

Config files:

Plugins:

HtmlWebpackPlugin: Uses src/index.html as the main entrypoint for the project.

DefinePlugin: Defines the following environment variables:

Variable default value Notes
ENV test, development, production The value is set automatically based on the running environment
PUBLIC_PATH / The context that the app is running in (e.g. /app if the app is accessible at https://<domain>/app). It can be set via PUBLIC_PATH environment variable and must end with a slash.

FaviconsWebpackPlugin: Generates favorite icons from the image in src/images/favicon.png.

MiniCssExtractPlugin: Extracts the styling from JS files into css files.

CleanWebpackPlugin: Removes and cleans up the build folder before a new build.

BundleAnalyzerPlugin: Provides information and analytics on the generated bundle. It can be accessed on localhost:8081 and is only available in development mode.

Typescript:

Linting (Eslint + Prettier):

Use npm run lint to see a list of linting issues.

Use npm run lint:fix to fix those issues that can be handled automatically.

Testing (Jest):

Use npm run test to run the test units.

Use npm run test:watch to start the test runner in watch mode.

Documentation (Typedoc):

Use npm run docs to generate docs.

Pre-commit hooks (Husky + lint-staged):

Repo

The repo has one Github workflow that checks the linting rules and runs the tests (see .github/workflows/test.yaml). There are issue and PR templates in .github.