|
1 | | -# micro-frontends-earn-app |
| 1 | +# micro-frontends-earn-app |
| 2 | + |
| 3 | +# Topcoder Earn App |
| 4 | + |
| 5 | +This is a [single-spa](https://single-spa.js.org/) example React microapp. |
| 6 | + |
| 7 | +> 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. |
| 8 | +
|
| 9 | +## Requirements |
| 10 | + |
| 11 | +- node - v10.22.1 |
| 12 | +- npm - v6.14.6 |
| 13 | + |
| 14 | +## NPM Commands |
| 15 | + |
| 16 | +Command | Description |
| 17 | +--------------------- | ----------------------------------------------------------------- |
| 18 | +`npm start` | Run server which serves production ready build from `dist` folder |
| 19 | +`npm run dev` | Run app in the development mode |
| 20 | +`npm run dev-https` | Run app in the development mode using HTTPS protocol |
| 21 | +`npm run build` | Build app for production and puts files to the `dist` folder |
| 22 | +`npm run analyze` | Analyze dependencies sizes and opens report in the browser |
| 23 | +`npm run lint` | Check code for lint errors |
| 24 | +`npm run format` | Format code using prettier |
| 25 | +`npm run test` | Run unit tests |
| 26 | +`npm run watch-tests` | Watch for file changes and run unit tests on changes |
| 27 | +`npm run coverage` | Generate test code coverage report |
| 28 | + |
| 29 | +## Local Deployment |
| 30 | + |
| 31 | +Inside the project folder run: |
| 32 | + |
| 33 | +- `export APPMODE="development"; export APPENV="local";` - to load APPMODE & APPENV |
| 34 | +- `nvm use 10.22.1;` - to use npm version: 10.22.1 |
| 35 | +- `npm i` - install dependencies |
| 36 | +- `npm run dev` - run app in development mode |
| 37 | +- As this app can be loaded only inside a frame single-spa, you have to run a `micro-frontends-frame` frame app and configure it to use the URL `http://localhost:8008/topcoder-micro-frontends-earn-app.js`. |
| 38 | + |
| 39 | +## Deployment to Production |
| 40 | + |
| 41 | +- `npm i` - install dependencies |
| 42 | +- `npm build` - build code to `dist/` folder |
| 43 | +- Now you can host `dist/` folder using any static server. For example, you may run a simple `Express` server by running `npm start`. |
| 44 | + |
| 45 | +### Deploying to Heroku |
| 46 | + |
| 47 | +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: |
| 48 | + |
| 49 | +- If there is not Git repository inited yet, create a repo and commit all the files: |
| 50 | + |
| 51 | + - `git init` |
| 52 | + - `git add .` |
| 53 | + - `git commit -m'inital commit'` |
| 54 | + |
| 55 | +- `heroku apps:create` - create Heroku app |
| 56 | + |
| 57 | +- `git push heroku master` - push changes to Heroku and trigger deploying |
| 58 | + |
| 59 | +- Now you have to configure frame app to use the URL provided by Heroku like `https://<APP-NAME>.herokuapp.com/topcoder-micro-frontends-earn-app.js` to load this microapp. |
0 commit comments