Ticket #2950 (closed requirement: fixed)

Opened 19 months ago

Last modified 19 months ago

paster command to minify javascript and css

Reported by: icmurray Owned by:
Priority: major Milestone: ckan 2.0
Component: ckan Keywords: frontend paster javascript fanstatic
Cc: Repository: ckan
Theme: none

Description (last modified by icmurray) (diff)

With the latest template, css and js changes in 2.0, there are a number of things that need preparation prior to a production deployment. One of these is:

  • the fanstatic_resources defined in ckan/lib/fanstatic_resources.py (bottom of module) should be prepared, and minified.

This ticket is to:

  • provide a paster command which when run will generate the minified javascript as css files.
  • stop the auto-minification of files when CKAN starts up.
  • remove reference to the minified files in the .gitignore file.
  • add instruction to the release process to run this command, and check-in the minified files to the repo.

## Background

Currently, minification works seamlessly without the need for any preparation when CKAN is started in a development setup. But on a production site, the webserver will (almost certainly) not have write-access to the directories that will contain the minified files. And so the minification will fail, and the site will end up serving the un-minified media, or even *old* minified media.

One way around this would be to allow webserver write access to the directory its serving out of. But this is not generally considered good practice.

Another method would be to distribute the minified files with CKAN. This ticket describes how to do this without causing a lot of noise in the commit history of the repo.

The auto-minifcation occurs when importing ckan/lib/fanstatic_resources.py.

## Changing the process slightly

The reason for moving away from auto-minifying files at start-up, to minifying files when running a paster command is:

  • we should be distributing the minified files when we make a release (as we do with translation files). This makes it easier to install CKAN from source.
  • if we distribute the minified files, then they need to be checked-in to the repo.
  • if they are auto-minified, whenever small changes are made, then this will create a lot of noise in the repo. It will be clearer to have the minified-files generated manually as part of the release process. (Or whever we make a deployment internally).

Change History

comment:1 Changed 19 months ago by icmurray

  • Summary changed from paster commands to prepare codebase for deployment to paster command to minify javascript

comment:2 Changed 19 months ago by toby

just a note to say fanstatic will serve minified files if it finds them in production even if they are old so we need to make sure they are up to date.

comment:3 Changed 19 months ago by icmurray

  • Description modified (diff)
  • Summary changed from paster command to minify javascript to paster command to minify javascript and css

comment:4 Changed 19 months ago by seanh

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.