Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assets in relative path on vite build #73

Open
jeroqui opened this issue Nov 26, 2024 · 1 comment
Open

assets in relative path on vite build #73

jeroqui opened this issue Nov 26, 2024 · 1 comment

Comments

@jeroqui
Copy link

jeroqui commented Nov 26, 2024

Hello,

on vite build, I find that its creating the bundled files under. Something like: ${BASE_DIR}/${BASE_DIR}

I mean that the files are created relative to the project root, but it creates the whole /home/user/projectpath inside the project...

I checked that variable, and its correctly set as **/**home/user/django_app_path/static... with the starting slash.

Is there some configuration I'm missing?

My vite.config.js is very simple:

import { defineConfig } from 'vite'
import { djangoVitePlugin } from 'django-vite-plugin'

export default defineConfig({
  plugins: [
    djangoVitePlugin([
      'ts/main.ts',
      'scss/main.scss',
    ])
  ],
});

I tried settings the entry point paths on this file as absolute paths, but then I get a bunch of error messages related to django's settings.

Django's settings are mostly the default ones. (actually from wagtail, but not much diference):

STATICFILES_FINDERS = [
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
]

STATICFILES_DIRS = [
    os.path.join(PROJECT_DIR, "static"),
]

STATIC_ROOT = os.path.join(BASE_DIR, "static")
STATIC_URL = "/static/"

MEDIA_ROOT = os.path.join(BASE_DIR, "media")
MEDIA_URL = "/media/"

I can't manage to understand why it would do that...

@protibimbok
Copy link
Owner

Did you try setting

DJANGO_VITE_PLUGIN = {
    'BUILD_DIR': getattr(settings, 'STATIC_ROOT') or 'static', # This value here
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants