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

Commit 32c8872

Browse files
author
Maria Mattlin
committed
PROD-1531 #comment Added shell scripts for running server and client locally. Updated readme with instructions #time 30m
1 parent c8afabb commit 32c8872

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ When developing one of the micro front-end applications you will therefore have
6363
- `local-ssl-proxy` server
6464
- the MFE app you're developing
6565

66-
Given this complexity, it is recommended that you use a tool like [iTerm2](https://iterm2.com) (on Mac) or an equivalent terminal shell on Windows to make terminal management simpler. iTerm2 allows you to setup a pre-defined window layout of terminal sessions, including the directory in which the session starts. With this setup, along with simple shell scripts in each project that configure and start the environment (#TODO), will allow you to get your development environment up and running quickly and easily.
66+
Given this complexity, it is recommended that you use a tool like [iTerm2](https://iterm2.com) (on Mac) or an equivalent terminal shell on Windows to make terminal management simpler. iTerm2 allows you to setup a pre-defined window layout of terminal sessions, including the directory in which the session starts. This setup, along with simple shell scripts in each project that configure and start the environment, will allow you to get your development environment up and running quickly and easily.
6767

6868
### Linting
6969
We use linting to enforce standardization. Please make sure all lint rules pass before creating PRs.
@@ -131,27 +131,28 @@ This `mfe-core` app has 2 types of configs:
131131
| Command | Description |
132132
| -------------------- | ---------------------- |
133133
| `npm start` | Run server which serves production ready build from `dist` folder |
134+
| `npm run start-server` | Run server locally for local development (calls on local-server npm script) |
135+
| `npm run start-client` | Run client locally for local development (calls on local-client npm script) |
134136
| `npm run build` | Build app with webpack and puts files to the `dist` folder |
135137
| `npm run local-server` | Run the server on local machine with nodemon |
136138
| `npm run local-client` | Run the frontend on local machine with webpack-dev-server |
137139
| `npm run lint` | Check code for lint errors |
138140
| `npm run format` | Format code using prettier |
139141
| `npm run test` | Run unit tests |
140142

141-
## Local Deployment from multi web servers (nodemon & webpack-dev-server) for local development
143+
## Local Deployment from multi web servers (nodemon & webpack-dev-server) for local development - (most common)
142144

143-
To deploy `mfe-core` app locally run inside the project root `./mfe-core`:
145+
To run the `mfe-core` app locally, run the following commands from the project root `./mfe-core`:
144146

145-
| Command | Description |
146-
| -------------------- | ---------------------- |
147-
| `$ export APPMODE="development"; export APPENV="local-multi"` | to add environment variables for application building on local |
148-
| `$ nvm use 10.22.1` | configure the required node and npm versions via nvm |
149-
| `$ npm i` | to install dependencies |
150-
| `$ npm run local-server` | to start the app on port `3000` |
151-
| `$ export APPMODE="development"; export APPENV="local-multi"; nvm use 10.22.1; npm i; npm run local-client` | to start the app on port `8080` (`run in another terminal`) |
152-
| `http://local.topcoder-dev.com:8080/micro-frontends-react-route` | open url in browser to access the micro frame with react micro app and micro navbar app |
147+
Terminal 1
148+
```
149+
$ npm run start-server
150+
```
153151
154-
⚠️ **NOTE** : for running locally, you have to use domain `local.topcoder-dev.com` with port `8080` & `3000`. On your local machine access file `/etc/hosts` add the line `127.0.0.1 local.topcoder-dev.com` and open app by URL http://local.topcoder-dev.com:8080
152+
Terminal 2
153+
```
154+
$ npm run start-client
155+
```
155156
156157
## Local Deployment from web server (node)
157158

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
"name": "@topcoder/mfe-core",
33
"scripts": {
44
"start": "node server.js",
5+
"start-server": "sh start-server.sh",
6+
"start-client": "sh start-client.sh",
57
"build": "webpack --mode=${APPMODE:-development} --env.APPENV=${APPENV:-dev} --env.SEGMENT_ANALYTICS_KEY=${SEGMENT_ANALYTICS_KEY:-NS}",
68
"local-server": "nodemon ./server.js",
79
"local-client": "webpack-dev-server --mode=development --port 8080 --env.APPENV=local",
@@ -45,4 +47,4 @@
4547
"single-spa-layout": "1.0.0-beta.12",
4648
"nodemon": "^2.0.6"
4749
}
48-
}
50+
}

start-client.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
#Load nvm
3+
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
4+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
5+
6+
export APPMODE="development"
7+
export APPENV="local-multi"
8+
9+
nvm use
10+
npm run local-client

start-server.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
#Load nvm
3+
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
4+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
5+
6+
export APPMODE="development"
7+
export APPENV="local-multi"
8+
9+
nvm use
10+
npm i
11+
npm run local-server

0 commit comments

Comments
 (0)