Problem with the vite django integration (TypeError)

I'm currently working on integrating Vite with my Django project using the django-vite package. However, upon running the Django development server, I encounter the following error:

TypeError: django_vite.core.asset_loader.DjangoViteConfig() argument after ** must be a mapping, not bool

Project Setup:

Django Version: 5.1.5​
django-vite Version: [Specify Version]​

Vite Configuration:
The vite.config.js is set to output build files to Django's static directory, and the manifest is enabled.​

Django Settings:
django_vite is added to INSTALLED_APPS.​

DJANGO_VITE configuration is defined as follows:

DJANGO_VITE = {
    "dev_mode": DEBUG,
    "manifest_path": os.path.join(BASE_DIR, "static", "manifest.json"),
    "static_url_prefix": STATIC_URL,
}

vite.config.ts

export default defineConfig({
  plugins: [react(), tailwindcss()],
  test: {
    globals: true,
    environment: "jsdom",
    setupFiles: "./src/setupTests.js",
    include: ["**/__tests__/**/*.{js,jsx,ts,tsx}"],
  },
  base: "/static/", // Entspricht dem STATIC_URL in Django
  build: {
    outDir: "../backend/static/", // Pfad zum statischen Ordner von Django
    manifest: true,
    rollupOptions: {
      input: "src/main.jsx", // Haupteinstiegspunkt
    },
  },
});

Error Details:

The traceback indicates the error originates from the DjangoViteConfig class in the django_vite package:

File "path_to_python_env\Lib\site-packages\django_vite\core\asset_loader.py", line 731, in _apply_django_vite_settings
    config = DjangoViteConfig(**config)
TypeError: django_vite.core.asset_loader.DjangoViteConfig() argument after ** must be a mapping, not bool

Configuration Verification: Ensured that the DJANGO_VITE settings are correctly defined as a dictionary.​

Dependencies Check: Verified that all related packages are up-to-date and compatible with each other.​

Code Review: Searched through the codebase to identify any unintended boolean values being passed where a mapping is expected.

Вернуться на верх