jaylett / django-and-pipelines

We'll come up with a better name later
6 stars 0 forks source link

Manifests for good

We're building (a) a manifest file format specification, (b) a series of examples for different pipelines of how to generate them, (c) a series of examples of how to integrate them with various web frameworks and template engines.

Pipelines

For each one, we aim for a simple pipeline that compiles one or two different things (perhaps scss and some coffeescript) and outputs the files with sourcemaps, revision/hashing, plus a manifest file that provides the mapping for those hashes.

Frameworks and template engines

Better Django integration

The goal would be to have the new assets-pipeline-stuff be compatible with the existing staticfiles module.

Ideally:

In details, this would mean:

The collectstatic would now be:

  1. Build a list of expected static files (logical paths)
  2. Look into pipeline manifests for those logical paths
    • If a manifest provides a local path for a file, copy it directly to the storage (the pipeline is expected to provide hashing) and add the logical path / target file pair to the (Django) manifest
    • If a manifest provides an URL for the file, just use that directly in the (Django) manifest
  3. For files that couldn't be found in the pipeline manifests, collect them as usual (first compute the hash, then write it to the storage) and add it to the (Django) manifest

At the end of those steps, external files will have been added to the Django manifest and into Django's storage backend, unless they are hosted at remote URLs (for instance on a CDN).

The changes to both the implicit extended Storage API used by collectstatic, and collectstatic itself (and probably the desirability of moving collectstatic into core, then overriding it in a contrib app to provide hashing behaviour) will probably necessitate a DEP.