Build UI
- Prerequisites
- Verify Installation
- Building the Frontend
- Running Locally with Docker
- Notes and Caveats
Prerequisites
Before starting, ensure your environment is properly set up:
-
Install Node.js
Use tools like fnm or nvm for Node.js version management. -
Install pnpm
Follow the instructions at pnpm.io. -
Install nx
Globally install nx for workspace management.
Verify Installation
Run the following commands to confirm the setup:
-
Check Node.js Version
node -v
Ensure the installed Node.js version matches the one in.nvmrc. -
Check pnpm Version
pnpm -v
Verify that pnpm is installed and accessible. -
Check nx Version
nx --version
Confirm that nx is properly installed.
Building the Frontend
Use the following command to build the frontend:
BASE_URL="$BASE_URL" nx run bublik:build --base="$BASE_URL" --outputPath=../dist/"$OUTPUT_FOLDER" --sourcemap="true"
Parameter Descriptions:
-
BASE_URL
Specifies the base path for the application (e.g.,/prefix/v2).- Ensure the path starts with a
/. - Do not include a trailing
/.
- Ensure the path starts with a
-
OUTPUT_FOLDER
The directory where static files will be output.
Running Locally with Docker
To run the UI locally using Docker:
-
Set Up Environment
Create a.env.localfile inapps/bublik/. Use the example fileapps/bublik/.env.local.exampleas a guide. -
Build the Docker Image
- Using pnpm:
pnpm run docker:build - Using Docker CLI:
docker build -f apps/bublik/Dockerfile.dev . -t bublik-ui
- Using pnpm:
-
Start the Docker Container
- Using pnpm:
pnpm run docker:start - Using Docker CLI:
docker run -it --rm -p 4200:4200 -v $(pwd):/app -v /app/node_modules --env-file apps/bublik/.env.local bublik-ui
- Using pnpm:
Notes and Caveats
-
Connecting to the Django Backend
If the Django backend is hosted locally, add the--network hostflag to thedocker runcommand.docker run --network host -it --rm -p 4200:4200 -v $(pwd):/app -v /app/node_modules --env-file apps/bublik/.env.local bublik-ui -
Rebuilding the Image
If you add new dependencies topackage.json, rebuild the Docker image to apply changes.pnpm run docker:build -
Accessing the UI
Once the container is running, access the UI athttp://localhost:4200.