This project was bootstrapped with Create React App and then eject and apply some imporvement on it.
- All packages are semver
latest
, no npm audit warning.- Package issues are fixed.
- Run GitHub Actions matrix CI on:
- Different OS (windows-2022 / macos-14 / ubuntu-22.04)
- Different Node.js version (maintenance LTS / active LTS / current)
- Add
pathRewrite
feature. - Add
npm run preview
, which share same proxy config with development server. - Add
npm run lint
foreslint
. - Add
npm run format
forprettier
. - Despite above features, behaves the same as Create React App
- Which means CRA documents can still be referenced
- Webpack, Babel, Jest, Browserslist, ESLint configs are all in
package.json
, behaves the same as CRA
- Add
proxy
andproxyRewrite
objects topackage.json
- According to CRA Proxy,
proxyRewrite
will not load unlessproxy
key is set. - Note:
src/setupProxy.js
will ignoreproxyRewrite
, which behaves the same as CRA.
{
"proxy": "https://jsonplaceholder.typicode.com/",
"proxyRewrite": {
"/api": "/",
"/other/api": "/"
}
}
In the project directory, you can run:
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.
Launches the test runner in the interactive watch mode.
See the section about running tests for more information.
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.
After build the app for production to the build
folder.
Preview the app in the prodiction mode.
Open http://localhost:3000 to view it in the browser.\
Preview server share same proxy config with development server.
Use eslint
to check issues.
Format codes with prettier
- Check pacakges manually and install proper version
npm i react@17 react-dom@17 @testing-library/react@12 @types/react@17 @types/react-dom@17
src/index.tsx
// prettier-ignore-start
import "react-app-polyfill/ie11";
// prettier-ignore-end
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import "./index.css";
import {
reportCLS,
reportFCP,
reportFID,
reportINP,
reportLCP,
reportTTFB,
} from "./reportWebVitals";
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root") as HTMLElement,
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportCLS(console.log))
// or send to an analytics endpoint. Learn more: https://github.com/GoogleChrome/web-vitals
reportCLS();
reportFCP();
reportFID();
reportINP();
reportLCP();
reportTTFB();
package.json
{
"browserslist": {
"production": [">0.2%", "not dead", "not op_mini all", "IE 11"],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
You can learn more in the Create React App documentation.
To learn React, check out the React documentation.