diff --git a/src/djinit/templates/project/Dockerfile-tpl b/src/djinit/templates/project/Dockerfile-tpl index 8095b7f..16ccf7c 100644 --- a/src/djinit/templates/project/Dockerfile-tpl +++ b/src/djinit/templates/project/Dockerfile-tpl @@ -18,7 +18,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* # @ENDIF -# @IF use_tailwind +# @IF use_tailwind or use_vite RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ && 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 # @ENDIF +# @IF use_vite +COPY package.json package-lock.json ./ +RUN npm ci +RUN npm run build +# @ENDIF + COPY . . RUN python manage.py collectstatic --noinput || true diff --git a/src/djinit/templates/project/ci/github_actions-tpl b/src/djinit/templates/project/ci/github_actions-tpl index 03648aa..92de094 100644 --- a/src/djinit/templates/project/ci/github_actions-tpl +++ b/src/djinit/templates/project/ci/github_actions-tpl @@ -30,6 +30,18 @@ jobs: - name: Install dependencies 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 run: uv run ruff check . diff --git a/src/djinit/templates/project/ci/gitlab_ci-tpl b/src/djinit/templates/project/ci/gitlab_ci-tpl index 41e4520..6120282 100644 --- a/src/djinit/templates/project/ci/gitlab_ci-tpl +++ b/src/djinit/templates/project/ci/gitlab_ci-tpl @@ -39,6 +39,10 @@ before_script: - python --version - pip install uv - uv sync +# @IF use_vite + - npm ci + - npm run build +# @ENDIF lint: stage: lint diff --git a/src/djinit/templates/project/gitignore-tpl b/src/djinit/templates/project/gitignore-tpl index 2b5243c..fb20bd7 100644 --- a/src/djinit/templates/project/gitignore-tpl +++ b/src/djinit/templates/project/gitignore-tpl @@ -71,7 +71,9 @@ yarn-debug.log* yarn-error.log* # Node modules (if using frontend tools) +# @IF use_tailwind or use_vite node_modules/ +# @ENDIF # Secret keys secret.txt diff --git a/src/djinit/templates/project/justfile-tpl b/src/djinit/templates/project/justfile-tpl index 0b2bd5a..6958caf 100644 --- a/src/djinit/templates/project/justfile-tpl +++ b/src/djinit/templates/project/justfile-tpl @@ -14,6 +14,17 @@ dev: dev-server HOST="0.0.0.0" PORT="8000": 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 makemigrations: uv run python manage.py makemigrations diff --git a/src/djinit/templates/project/pyproject.toml-tpl b/src/djinit/templates/project/pyproject.toml-tpl index 532123a..cfc3a4a 100644 --- a/src/djinit/templates/project/pyproject.toml-tpl +++ b/src/djinit/templates/project/pyproject.toml-tpl @@ -11,7 +11,7 @@ dependencies = [ "django-jazzmin", "djangorestframework", "djangorestframework-simplejwt", - "drf-spectacular", + "drf-yasg", "django-cors-headers", "whitenoise", # @IF database_type == 'mysql' diff --git a/src/djinit/templates/project/requirements-tpl b/src/djinit/templates/project/requirements-tpl index 9dbb655..355ed8c 100644 --- a/src/djinit/templates/project/requirements-tpl +++ b/src/djinit/templates/project/requirements-tpl @@ -7,7 +7,7 @@ django-environ django-jazzmin djangorestframework djangorestframework_simplejwt -drf-spectacular +drf-yasg django-cors-headers whitenoise django-tailwind-cli # @IF use_tailwind