feat(templates): add Vue.js scaffolding and related template files

Add Vue.js frontend scaffolding to djinit, generating necessary Vue/Vite templates and updating conditionals for use_vue support.

- New Features
  - Add Vue.js template files: index-vue.html-tpl, App.vue-tpl, main.js-tpl, style.css-tpl.
  - Generate package-vue.json-tpl with Vite + Vue dependencies.
  - Create vite-vue.config.js-tpl for Vite configuration.
- Enhancements
  - Update base.py-tpl to conditionally load django-vite when use_vite | use_vue.
  - Add django-vite dependency in requirements-tpl under use_vue.
- Bug Fixes  - None.
This commit is contained in:
sankalp committed 2026-05-11 00:30:11 +05:45
1 parent 81830d981b
commit 6baa751543
8 files changed
+98 -2

No files matched your search

@@ -28,7 +28,7 @@ THIRD_PARTY_APPS = [
"drf_spectacular",
"django_tailwind_cli", # @IF use_tailwind
"django_htmx", # @IF use_htmx
"django_vite", # @IF use_vite
"django_vite", # @IF use_vite | use_vue
]
USER_DEFINED_APPS = [
@@ -227,7 +227,7 @@ TAILWIND_CLI_CONFIG = {
}
# @ENDIF
# @IF use_vite
# @IF use_vite | use_vue
# for django-vite
DJANGO_VITE_ASSET_SRC = "frontend"
DJANGO_VITE_DEV_SERVER_URL = "http://localhost:5173"
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>[[ project_name ]]</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
@@ -0,0 +1,17 @@
<script setup>
</script>
<template>
<div class="container">
<h1>Welcome to [[ project_name ]]</h1>
<p>This is your Vue.js frontend powered by Vite.</p>
<p>Edit <code>frontend/src/App.vue</code> to get started!</p>
</div>
</template>
<style scoped>
.container {
padding: 2rem;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
</style>
@@ -0,0 +1,5 @@
import { createApp } from 'vue'
import App from './App.vue'
import './style.css'
createApp(App).mount('#app')
@@ -0,0 +1,14 @@
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
line-height: 1.5;
}
#app {
min-height: 100vh;
}
@@ -0,0 +1,22 @@
#--------------------------------------------------#
# The following was generated by djinit: #
#--------------------------------------------------#
{
"name": "[[ project_name ]]-frontend",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.5.13"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.2.3",
"vite": "^6.3.5"
}
}
@@ -13,6 +13,7 @@ whitenoise
django-tailwind-cli # @IF use_tailwind
django-htmx # @IF use_htmx
django-vite # @IF use_vite
django-vite # @IF use_vue
pytest # @IF use_pytest
pytest-django # @IF use_pytest
pytest-cov # @IF use_pytest
@@ -0,0 +1,25 @@
#--------------------------------------------------#
# The following was generated by djinit: #
#--------------------------------------------------#
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
export default defineConfig({
plugins: [vue()],
root: 'frontend',
build: {
outDir: '../static/dist',
emptyOutDir: true,
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'frontend/src'),
},
},
server: {
port: 5173,
strictPort: true,
},
})