Pythoner
Pythoner

Reputation: 281

How to let Django see files under dist/static generated by Vue.js compilation?

I'd like to know how to specify static directory for Django in the following case.

Directory tree

root
├── vue_proj
│      └── dist
│           ├── index.html <- SPA, and no Django template in this.
│           └── static <- I wouldd like to let Django see this dir!
│                 └── js
│                      └── bundle.js
└── django_proj <- I executed "django-admin startproject project" here.
       └── project <- I executed "django-admin startapp app" here.
             ├── manage.py
             ├── app 
             └── project
                   ├── settings.py <- What should I do here?

So far I could let Django see dist/index.html by setting TEMPLATES parameter to ../vue_proj/dist.
I tried the follows but resulted in failure of loading js files...

STATIC_ROOT = '../vue-proj/dist'
STATIC_URL = '/static/'

Upvotes: 3

Views: 618

Answers (1)

Ankit Tiwari
Ankit Tiwari

Reputation: 4690

try this

STATICFILES_DIRS = [

    BASE_DIR.parent / "vue-proj/dist/static'",
]

static root is use for production it will collect all your css and js from static folder to static root dir.

STATIC_ROOT = BASE_DIR.parent / "static_cdn"

Upvotes: 3

Related Questions