Skip to main content
=====================
django-grunted-assets
=====================

Goal
====

- Have css and js compressed and cache busted in production
- Have livereload work with css injection in development
- Have livereload work with coffee-script files and html templates
- Have node serve our staticfiles in development as it is way faster than
django's runserver
- Give the flexibility that compressor provides, linking arbitrary files in certain templates and locations

Where django-compressor falls short
===================================

- Slow compile and reload
- No css injection with livereload
- Not the tools that grunt provides (autoprefixer, uglify, etc)
- Inlining assets

How it works
============

1. Put your static where you normally do, e.g. in a top level 'static' or
'assets' dir, or in the 'static' dir in your app.
2. Configure the paths in your gruntfile.
3. Add ``{% load grunted_assets %}`` to your (base) template and link the
assets you want to load with: ``{% link_asset 'script.js' %}``
4. Run grunt (see below).
5. Run ``django-admin.py collectstatic``

The ``link_asset`` template tag (or the ``inline_asset`` tag), searches for the
files in either ``.tmp`` (development) or ``dist`` (production) within
``STATIC_ROOT``.

The argument you pass to ``link_asset`` of ``inline_asset`` is treated as a regex. A
simple ``main.css`` therefore works, but using ``.*main\.js`` for example, you can
also match files processed with something like
``grunt-rev<https://www.npmjs.com/package/grunt-rev>``_.

Development
-----------

In development (``grunt`` or ``grunt develop``), grunt compiles sass and coffee-
script to a ``.tmp`` dir inside 'static'. These files get served by node. No
cache busting here.

All static will be served by ``connect`` on ``localhost:8001``, so set
``STATIC_URL='http://localhost:8001``

Production
----------

Run ``grunt dist`` and check the ``dist`` folder into source control. This will
concat, minify etc. all your js and css into 'main.css' and 'main.js' as you
specify in your gruntfile.

On the server run ``django-admin.py collectstatic`` to have all static files
collected to the proper place.

Metadata

Release files for django-grunted-assets 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-grunted-assets 0.2.1
File Size Uploaded
django-grunted-assets-0.2.1.tar.gz 3.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-grunted-assets 0.2.1
File Interpreter ABI Platform
django_grunted_assets-0.2.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 9.9 kB

Release files / django-grunted-assets-0.2.1.tar.gz

Download URL django-grunted-assets-0.2.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b49261aebbe033915fd8eb450c50c59d7cd5679ba5feaf6e0055dcbbca197aa3
BLAKE2b-256 checksum
How to use checksums
f36124432efef0b7b8fe542f64dfebf1c8c45100f2701fa2c2c21364cc46dc0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_grunted_assets-0.2.1-py2.py3-none-any.whl

Download URL django_grunted_assets-0.2.1-py2.py3-none-any.whl
Size 6.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
212ac78c7116122e51b067c795b0825abfcce6a35156622dbc6b5b3215472b67
BLAKE2b-256 checksum
How to use checksums
2a0323970c3e23b301574dd01277b65c012ff4b62bfae7dbbdc9a6fd9305cf56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page