- Notifications
You must be signed in to change notification settings - Fork16
topcoder-archive/topcoder-platform-micro-frontends-earn-app
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
This is asingle-spa example React microapp.
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 framesingle-spa 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-spaapproch, see thisGitHub Issue for details.
- node - v10.22.1
- npm - v6.14.6
| Command | Description |
|---|---|
npm start | Run server which serves production ready build fromdist folder |
npm run dev | Run app in thedevelopment mode anddev config |
npm run dev-https | Run app in thedevelopment mode anddev config using HTTPS protocol |
npm run prod | Run app in thedevelopment mode andprod config |
npm run build | Build app for production and puts files to thedist folder, default todevelopment mode anddev config |
npm run analyze | Analyze dependencies sizes and opens report in the browser |
npm run lint | Check code for lint errors |
npm run format | Format code using prettier |
npm run test | Run unit tests |
npm run watch-tests | Watch for file changes and run unit tests on changes |
npm run coverage | Generate test code coverage report |
Inside the project folder run:
nvm use 10.22.1;- to use npm version: 10.22.1npm i- install dependenciesnpm run dev- run app indevelopmentmode anddevconfig, currently it is using the config fromdefault.js- As this app can be loaded only inside a frame single-spa, you have to run a
mfe-coreframe app and configure it to use the URLhttp://localhost:8008/earn-app/topcoder-micro-frontends-earn-app.js.
The setup is assuming you have setup the
mfe-coreandmicro-frontends-nav-app. And this is also assuming your have a new MFE namedanother-appand your local url ishttp://localhost:8099/another-app/topcoder-micro-frontends-another-app.jsYou have launched existing
micro-frontends-challenges-appandmicro-frontends-gigs-appin your local envrionment.Modify the
config/dev.jsby incorporating the module mapping, so it might be look like this if you setup all them in local environment:
module.exports = { MFE_CONFIG: { '@topcoder/micro-frontends-another-app': 'http://localhost:8099/another-app/topcoder-micro-frontends-another-app.js', '@topcoder/micro-frontends-challenges-app': 'http://localhost:8009/challenges-app/topcoder-micro-frontends-challenges-app.js', '@topcoder/micro-frontends-gigs-app': 'http://localhost:8010/gigs-app/topcoder-micro-frontends-gigs-app.js', }};In the
src/containers/Menu/index.jsx, you can modify it to add your newanother-appmenu link, challenges-app and gigs-app menu links have already been setup as reference.In the
set-public-path.jsfile, add the mapping to youranother-app, challenges-app and gigs-app have already been setup as the reference.In the
src/App.jsxfile, add the application mount point inside the<Router>component, challenges-app and gigs-app have already been setup as the referenceEdit your
hostsfile by mapping127.0.0.1 local.topcoder-dev.comNow visit
http://local.topcoder-dev.com:8080/earn/find/challengesto view themicro-frontends-challenges-app
npm i- install dependenciesAPPMODE=production APPENV=prod npm run build- build code todist/folder- Now you can host
dist/folder using any static server. For example, you may run a simpleExpressserver by runningnpm start.
Make sure you haveHeroky CLI installed and you have a Heroku account. And then inside the project folder run the next commands:
If there is not Git repository inited yet, create a repo and commit all the files:
git initgit add .git commit -m'inital commit'
heroku apps:create- create Heroku appgit push heroku master- push changes to Heroku and trigger deployingNow you have to configure frame app to use the URL provided by Heroku like
https://<APP-NAME>.herokuapp.com/earn-app/topcoder-micro-frontends-earn-app.jsto load this microapp.
About
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Contributors12
Uh oh!
There was an error while loading.Please reload this page.