This project requires Node.js 8+ to build. It won't work well without the product-service and inventory-service running.
- Create a file called
.env
in<project>/src/frontend/
- Put two variables in it,
PRODUCT_SERVICE_BASE_URL
andINVENTORY_SERVICE_BASE_URL
with the correct URLs to your service.- If running locally, copy the snippet below.
- If running in production, make sure the URLs match where the services are
- Make sure CORS headers are set correctly in other services
PRODUCT_SERVICE_BASE_URL=http://localhost:8000
INVENTORY_SERVICE_BASE_URL=http://localhost:5000
- (Optional) Set
APPINSIGHTS_INSTRUMENTATIONKEY
with Applications Insights key (enables Application Insights) - (Optional) Set
DISPLAY_SQL_INFO
=true
to display SQL Server information from Inventory Service. Leave empty if you don't want to show this.
cd
to this directory,<project>/src/frontend/
npm install
npm run dev
- Open http://localhost:1234 in your browser
- Adhere to the Prettier and ESLint rules before checking in
cd
to this directory,<project>/src/frontend/
npm install
npm run build
- Project will be built in
<project>/src/frontend/dist
- Parcel (the bundler used here) has a hard time when you change
.env
variables on it. When you change you.env
, delete the.cache/
anddist/
directories and then run a new build.
You can build this app super easily with Docker:
docker build -t twt-fe .
That will build and minimize all assets for you. Then you can run it with:
docker run --rm -d -p 8080:8080 -e PRODUCT_SERVICE_BASE_URL=https://product-service-base-url -e INVENTORY_SERVICE_BASE_URL=https://inventory-service-base-url twt-fe
Pass in the proper product and inventory service base URLs at startup. Then you can go check it out at http://localhost:8080
.