feat(src/djinit/templates/project): add Vite support and update dependency handling

Introduce Vite‑based frontend workflow and adjust related templates and CI configurations. Switch drf‑spectacular to drf‑yasg, add conditional Node.js setup, and update ignored files accordingly.

- New Features
  - Conditional Vite integration via `use_vite` flag
  - npm install and build steps added to Dockerfile and CI pipelines
  - Vite dev server command added to `justfile` with `dev-full` target
  - Updated CI scripts (GitHub Actions, GitLab CI) to run Vite build when enabled
  - Dependency change from `drf-spectacular` to `drf-yasg` in `pyproject.toml`

- Enhancements
  - Modify `.gitignore` to exclude `node_modules` only when using frontend tools
  - Update Dockerfile to conditionally install Node.js packages for Vite
  - Adjust GitHub Actions and GitLab CI templates to include Node setup steps

- Bug Fixes
  - Replace `drf-spectacular` with `drf-yasg` to align with current API documentation practices
This commit is contained in:
sankalp committed 2026-05-28 10:08:19 +05:45
1 parent 197e35948f
commit 7a9563957d
7 files changed
+38 -3

No files matched your search

+7 -1
View File
@@ -18,7 +18,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# @ENDIF # @ENDIF
# @IF use_tailwind # @IF use_tailwind or use_vite
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
curl \ curl \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
@@ -35,6 +35,12 @@ RUN pip install --no-cache-dir -r requirements.txt
RUN python manage.py tailwind install RUN python manage.py tailwind install
# @ENDIF # @ENDIF
# @IF use_vite
COPY package.json package-lock.json ./
RUN npm ci
RUN npm run build
# @ENDIF
COPY . . COPY . .
RUN python manage.py collectstatic --noinput || true RUN python manage.py collectstatic --noinput || true
@@ -30,6 +30,18 @@ jobs:
- name: Install dependencies - name: Install dependencies
run: uv sync run: uv sync
# @IF use_vite
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build frontend
run: |
npm ci
npm run build
# @ENDIF
- name: Run linting - name: Run linting
run: uv run ruff check . run: uv run ruff check .
@@ -39,6 +39,10 @@ before_script:
- python --version - python --version
- pip install uv - pip install uv
- uv sync - uv sync
# @IF use_vite
- npm ci
- npm run build
# @ENDIF
lint: lint:
stage: lint stage: lint
@@ -71,7 +71,9 @@ yarn-debug.log*
yarn-error.log* yarn-error.log*
# Node modules (if using frontend tools) # Node modules (if using frontend tools)
# @IF use_tailwind or use_vite
node_modules/ node_modules/
# @ENDIF
# Secret keys # Secret keys
secret.txt secret.txt
+11
View File
@@ -14,6 +14,17 @@ dev:
dev-server HOST="0.0.0.0" PORT="8000": dev-server HOST="0.0.0.0" PORT="8000":
uv run python manage.py runserver {{ HOST }}:{{ PORT }} uv run python manage.py runserver {{ HOST }}:{{ PORT }}
# @IF use_vite
# Start Vite dev server
vite:
npm run dev
# Start both Django and Vite dev servers
dev-full:
@just dev &
@just vite
# @ENDIF
# Create migrations for all apps # Create migrations for all apps
makemigrations: makemigrations:
uv run python manage.py makemigrations uv run python manage.py makemigrations
@@ -11,7 +11,7 @@ dependencies = [
"django-jazzmin", "django-jazzmin",
"djangorestframework", "djangorestframework",
"djangorestframework-simplejwt", "djangorestframework-simplejwt",
"drf-spectacular", "drf-yasg",
"django-cors-headers", "django-cors-headers",
"whitenoise", "whitenoise",
# @IF database_type == 'mysql' # @IF database_type == 'mysql'
@@ -7,7 +7,7 @@ django-environ
django-jazzmin django-jazzmin
djangorestframework djangorestframework
djangorestframework_simplejwt djangorestframework_simplejwt
drf-spectacular drf-yasg
django-cors-headers django-cors-headers
whitenoise whitenoise
django-tailwind-cli # @IF use_tailwind django-tailwind-cli # @IF use_tailwind