This is for folks who would like to work on the django-cms core package’s frontend code. For example:
- What node version do I have to use to build django-cms frontend bundles?
- I encounter errors when trying to build the frontend bundles
- How can I set up a frontend development environment?
- How can I compile the CSS & JS bundles?
django-cms is (still) using gulp and webpack as part of the frontend building pipeline. The building command is gulp
. The gulpfile.js
contains all available commands and their logic.
Docs:
- https://docs.django-cms.org/en/latest/contributing/code.html#contributing-frontend
- https://docs.django-cms.org/en/latest/contributing/testing.html#running-frontend-tests
Hint: You can always check the requirements for a successfully building frontend here: https://github.com/django-cms/django-cms/blob/develop-4/.github/workflows/frontend.yml
Below is a working Docker configuration that successfully builds the frontend bundles. Add these two files into the project root of your django-cms code repo:
In gulpfile.js
add host
(and optionally port
) configuration so you can later access that port from your host system:
...
const watchFiles = () => {
browserSync.init({
host: '0.0.0.0', // Listen on all network interfaces (for Docker)
port: 3000,
});
gulp.watch(PROJECT_PATTERNS.sass, css);
gulp.watch(PROJECT_PATTERNS.js, lint);
};
...
Dockerfile.dev.frontend:
FROM node:18.19.0 as build
# Set the working directory in the container
WORKDIR /app
# Copy package.json and package-lock.json to the working directory
COPY package*.json ./
# Install any needed packages specified in package.json
RUN npm install
# Copy the rest of the application code to the working directory
COPY . .
# Install gulp globally
RUN npm install -g gulp
# Expose the port your app runs on
EXPOSE 3000
# Define the command to run your app
CMD ["gulp", "bundle"]
docker-compose.dev-frontend.yml:
services:
frontend:
build:
context: .
dockerfile: Dockerfile.dev.frontend
volumes:
- .:/app
- /app/node_modules
ports:
- "3001:3001"
- "3000:3000"
environment:
- NODE_ENV=development
command: gulp bundle
Execute like this:
docker compose -f docker-compose.dev-frontend.yml run --service-ports frontend gulp watch
docker compose -f docker-compose.dev-frontend.yml run --service-ports frontend gulp bundle