Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 3a4cb0e

Browse files
committed
Baseline for the React App
1 parent 3b3aee3 commit 3a4cb0e

13 files changed

+15493
-1
lines changed

.eslintrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": ["react-important-stuff", "plugin:prettier/recommended"],
3+
"parser": "babel-eslint"
4+
}

.prettierignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.gitignore
2+
.prettierignore
3+
yarn.lock
4+
yarn-error.log
5+
package-lock.json
6+
dist
7+
coverage

README.md

+51-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,51 @@
1-
# micro-app-react
1+
# Topcoder React Microapp Example
2+
3+
This is a [single-spa](https://single-spa.js.org/) example React microapp.
4+
5+
> NOTE. This application have been configured to be run as child app of a single-spa application. So while this app can be deployed and run independently, we would need some frame [single-spa](https://single-spa.js.org/) which would load it. While technically we can achieve running this app as standalone app it's strongly not recommended by the author of the `single-spa` approch, see this [GitHub Issue](https://github.com/single-spa/single-spa/issues/640) for details.
6+
7+
## Requirements
8+
9+
- Node.js 8+
10+
- Npm 6+
11+
12+
## NPM Commands
13+
14+
| Command | Description |
15+
| --------------------- | ----------------------------------------------------------------- |
16+
| `npm start` | Run server which serves production ready build from `dist` folder |
17+
| `npm run dev` | Run app in the development mode |
18+
| `npm run dev-https` | Run app in the development mode using HTTPS protocol |
19+
| `npm run build` | Build app for production and puts files to the `dist` folder |
20+
| `npm run analyze` | Analyze dependencies sizes and opens report in the browser |
21+
| `npm run lint` | Check code for lint errors |
22+
| `npm run format` | Format code using prettier |
23+
| `npm run test` | Run unit tests |
24+
| `npm run watch-tests` | Watch for file changes and run unit tests on changes |
25+
| `npm run coverage` | Generate test code coverage report |
26+
27+
## Local Deployment
28+
29+
Inside the project folder run:
30+
31+
- `npm i` - install dependencies
32+
- `npm run dev` - run app in development mode
33+
- As this app can be loaded only inside a frame single-spa, you have to run a `root-config` frame app and configure it to use the URL `http://localhost:8500/topcoder-micro-frontends-react-app.js`.
34+
35+
## Deployment to Production
36+
37+
- `npm i` - install dependencies
38+
- `npm build` - build code to `dist/` folder
39+
- Now you can host `dist/` folder using any static server. For example, you may run a simple `Express` server by running `npm start`.
40+
41+
### Deploying to Heroku
42+
43+
Make sure you have [Heroky CLI](https://devcenter.heroku.com/articles/heroku-cli) installed and you have a Heroku account. And then inside the project folder run the next commands:
44+
45+
- If there is not Git repository inited yet, create a repo and commit all the files:
46+
- `git init`
47+
- `git add .`
48+
- `git commit -m'inital commit'`
49+
- `heroku apps:create` - create Heroku app
50+
- `git push heroku master` - push changes to Heroku and trigger deploying
51+
- Now you have to configure frame app to use the URL provided by Heroku like `https://<APP-NAME>.herokuapp.com/topcoder-micro-frontends-react-app.js` to load this microapp.

babel.config.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react"],
3+
"plugins": [
4+
[
5+
"@babel/plugin-transform-runtime",
6+
{
7+
"useESModules": true,
8+
"regenerator": false
9+
}
10+
]
11+
],
12+
"env": {
13+
"test": {
14+
"presets": [
15+
[
16+
"@babel/preset-env",
17+
{
18+
"targets": "current node"
19+
}
20+
]
21+
]
22+
}
23+
}
24+
}

jest.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
rootDir: "src",
3+
transform: {
4+
"^.+\\.(j|t)sx?$": "babel-jest",
5+
},
6+
moduleNameMapper: {
7+
"\\.(css)$": "identity-obj-proxy",
8+
},
9+
setupFilesAfterEnv: [
10+
"../node_modules/@testing-library/jest-dom/dist/index.js",
11+
],
12+
};

0 commit comments

Comments
 (0)