Deploying Dash "improved_tabs" branch from github repo

Hi,

I’ve been using the “improved_tabs” branch from the dash-core-components github repository and it’s working well locally but when I try to deploy it to an external server using gunicorn/nginx I run into issues finding the relevant css/js files. Unsurprising since I’ve set

app.css.config.serve_locally = True
app.scripts.config.serve_locally = True

I tried commenting these lines out, but since it’s a dev branch unpkg doesn’t have the packages. (GET https://unpkg.com/dash-core-components@0.24.0/dash_core_components/bundle.js 404 ())

It seems to me that the next step would be to find all of the files required; stick them in a /static directory somewhere and have nginx alias /_dash-component-suites/ to the static directory.

Before I headed out to do that though I thought I’d ask if there’s a better / accepted way to deploy the Dash app where the scripts and css are hosted locally. As mentioned I’m using nginx/gunicorn and all other dash packages apart from core-components are the versions found using pip.

Hi @davepeake, the improved_tabs branch is now available as a prerelease, as version 0.24.0rc1. So you can run pip install dash_core_components==0.24.0rc1 or update your requirements.txt accordingly. Let me know if this works out for you!

That’s great, thanks! I already have the improved tabs working locally by using the github repo, but that will make it a lot easier in the future.

I’m mostly interested in if anyone has deployed it on a server using nginx/gunicorn since (it seems) you have to host the js/css locally, and the standard dash install makes it so easy by pulling in the packages from unpkg.com.

Maybe I’m missing something obvious here, though. It’s always a possibility!

So if you use the prerelease version, Dash can find the package on unpkg.com, so you don’t have to host the js/css locally. i.e. https://unpkg.com/dash-core-components@0.24.0-rc1/dash_core_components/bundle.js will work. Can you try using the prerelease version and commenting out the css/js serve_locally lines?

Awesome, so I am missing the point. As per normal my ignorance is the best possible outcome!

I’ll give it a shot and let you know.

Thanks!

Soooo close. I uninstalled the version of dash-core-components I had with

pip uninstall dash-core-components 

and then did the install using pip

pip install dash_core_components==0.24.0rc1

Still works serving the js/css locally, but when I try to use unpkg it attempts to link to the stylesheet:

https://unpkg.com/dash-core-components@0.24.0rc1/dash_core_components/react-dates@12.3.0.css

Which doesn’t exist, what does exist is -

https://unpkg.com/dash-core-components@0.24.0-rc1/dash_core_components/react-dates@12.3.0.css

ie. the dash before the rc1 isn’t present in my files. Here is a pastebin of the html that Dash is generating - https://pastebin.com/6R9PZiSL

I get the feeling I’m doing something silly here. Otherwise, maybe I can just add the dash somewhere in the ahem dash code?

Hi Dave, you are absolutely right - I made a mistake when releasing the prerelease version and as you rightly pointed out it tries to get the CSS with 0.24.0rc1 instead of 0.24.0-rc1. I’ve since published version 0.24.0rc2 (notice the rc2) which should fix that. I replied on the PR thread here https://github.com/plotly/dash-core-components/pull/213 but I forgot to mention this here too, sorry! Hope you didn’t spend too much time on it. Let me know if it works out!

No worries, thanks for the quick turn around. I’ll try it and get back to you.

Superb, it seems to be working now. Well your part is working, now I just have some nginx issues to figure out.

Thanks for your help, I really appreciate it.

2 Likes