Registry / web-framework / django-vite-plugin

django-vite-plugin

JSON →
library4.1.2jsnpmunverified

Django plugin for Vite (v4.1.2) — integrates Vite frontend assets with Django backend. Release cadence: active, monthly releases. Key differentiators: uses Python side django-vite-plugin pip package, supports Vite 5/6/7, handles HMR, React support, and aliases. Alternative to django-vite and django-webpack-loader.

npm install django-vite-plugin
INSTALL
IMPORT
SIG · DJANGO-VITE-PLUGIN
D
django-vite-plugin
web-frameworkjavascriptv4.1.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

djangoVitePlugin
import { djangoVitePlugin } from 'django-vite-plugin'
import djangoVitePlugin from 'django-vite-plugin'
Named export; default export not available.
djangoVitePlugin
const { djangoVitePlugin } = require('django-vite-plugin')
const djangoVitePlugin = require('django-vite-plugin')
CJS require must destructure named export.
type DjangoVitePluginOptions
import type { DjangoVitePluginOptions } from 'django-vite-plugin'
import { DjangoVitePluginOptions } from 'django-vite-plugin'
Type-only import to avoid bundling at runtime. Available in v4+.

Sets up Vite with Django plugin: specifies entry points, output directory, manifest, and dev server port.

// vite.config.js import { defineConfig } from 'vite' import { djangoVitePlugin } from 'django-vite-plugin' export default defineConfig({ plugins: [ djangoVitePlugin([ 'home/js/app.js', 'home/css/style.css', ]) ], build: { outDir: 'static_bundles', manifest: true, }, server: { port: 5173, strictPort: true, }, })
Debug
Known issues
breakingv4.0.0 changed the plugin signature from (options) to (inputs, options?). Old code using djangoVitePlugin({...}) will break.
fix
Update to new signature: djangoVitePlugin(['entry1.js', 'entry2.css'], { ... })
affects: >=4.0.0 <4.1.0
breakingIn v4.1.0, plugin no longer merges its input with vite config's input. If you relied on automatic merging, your entry points may be ignored.
fix
Ensure all entry points are passed to djangoVitePlugin() array.
affects: >=4.1.0
deprecatedThe 'outputDir' option was deprecated in v4.0.0 in favor of Vite's 'build.outDir'.
fix
Use 'build.outDir' in Vite config instead of plugin option 'outputDir'.
affects: >=4.0.0
gotchaReact HMR support requires additional configuration with 'react' plugin and correct alias setup.
fix
Ensure you have '@vitejs/plugin-react' installed and configured alongside djangoVitePlugin.
affects: >=4.0.5
gotchaESM-only since v4.0.2-npm; if your project uses CommonJS, you must upgrade to ESM or use dynamic import()
fix
Set 'type': 'module' in package.json or rename config to .mjs
affects: >=4.0.2-npm
Errors
Common errors & fixes
Error: __dirname is not defined in ES module scope
Using ESM (type: module) but code references __dirname which is not available in ESM.
fix
Use import.meta.url to derive __dirname: const __dirname = dirname(fileURLToPath(import.meta.url)); or avoid __dirname entirely.
TypeError: djangoVitePlugin is not a function
Default import used instead of named import.
fix
Change to: import { djangoVitePlugin } from 'django-vite-plugin'
Error: Cannot find module 'django-vite-plugin'
Package not installed or not in node_modules. Also may be due to old npm cache.
fix
Run: npm install django-vite-plugin
Error: [plugin: django-vite] No manifest found at...
Build not run before production mode or manifest path is incorrect.
fix
Run 'vite build' to generate manifest, and ensure Vite config has build.manifest: true.
Upgrade
Version history
4.1.2latest on npm
Audit
Dependencies
viterequiredpeer dependency, Vite core required
Agent activity
22 hits · last 30 days
node
20
Resources
django-vite-plugin — npm install django-vite-plugin · libregistry