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

Refactor static file handling #430

Open
2 of 5 tasks
jezdez opened this issue Feb 16, 2017 · 2 comments
Open
2 of 5 tasks

Refactor static file handling #430

jezdez opened this issue Feb 16, 2017 · 2 comments

Comments

@jezdez
Copy link
Contributor

jezdez commented Feb 16, 2017

There are a few things I've found while looking how Cabot organizes the static files:

  • the dependency on Less.js exists for a small file (base.less) which could easily be committed compiled
  • the use of django-compressor's compress blocks are used a lot for little gain
  • the static files should be shipped pre-compiled, compressed and collected with the Docker image, ready to be served

I'd like to propose (and contribute) some steps that could simplify the setup:

  • move to django-pipeline which uses Django's staticfiles app and has compiler and compression support built in
  • remove Less.js dependency by compiling base.less to base.css and commit it
  • move coffescript blocks into own files under cabot/static/js/<template-name>.js, e.g. cabot/static/js/service-list.coffee, which is included with a script tag in cabot/templates/cabotapp/service_list.html
  • start to use whitenoise as a way to serve the resulting compiled, collected and compressed static files
  • call collectstatic to trigger this whole thing in the Dockerfile to bake the static files into the image, fewer moving parts during deployment

I'm wondering if I'm missing something obvious, but I think this would be a big win for Cabot. In terms of reference that I can pull this off, I wrote django-staticfiles and co-wrote django-compressor. Please let me know if you're interested in that direction.

@dbuxton
Copy link
Contributor

dbuxton commented Feb 17, 2017

I think this sounds amazing @jezdez - I haven't seen whitenoise before but it looks like a godsend. The whole code layout wasn't thought through well and any reorganization would be gratefully received.

@frankh
Copy link
Contributor

frankh commented Feb 17, 2017

@jezdez sounds awesome

I've already merged in whitenoise - i was already looking at ways to serve the static files from docker and this is perfect, thanks

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

3 participants