The Django application that allows install and serve assets via Node.js package manager infrastructure.
Project description
The Django application that allows install and serve static assets via Node.js package manager infrastructure. The application exposes management command to install dependencies from your package.json and several static files finders to find files from installed node packages and exclude metadata of node packages and unwanted files when static files will be collected via Django`s collectstatic management command execution.
Features
Avoiding vendoring static assets in your repository like jQuery plugins, Bootstrap toolkit, etc
Avoiding mess in STATIC_ROOT through exclusion node packages` metatadata and unwanted files
Installing dependencies by Django`s management command
Installation
$ pip install django-node-assets
Configuration
Add ‘django_node_assets’ to your INSTALLED_APPS:
INSTALLED_APPS = [
...
'django_node_assets',
]
Add NodeModulesFinder to STATICFILES_FINDERS:
STATICFILES_FINDERS = [
...
'django_node_assets.finders.NodeModulesFinder',
]
Specify absolute path to the package.json file:
NODE_PACKAGE_JSON = '/var/assets/package.json'
Specify the absolute path to a directory where the nmpinstall management command will install assets:
NODE_MODULES_ROOT = '/var/assets/node_modules'
Specify path to the node package manager executable (optional)
NODE_PACKAGE_MANAGER_EXECUTABLE = '/usr/local/bin/npm'
Usage
Call the nmpinstall management command to install dependencies specified in the package.json
$ python manage.py npminstall
Use Django`s static template tag to link installed assets
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'bootstrap/dist/css/bootstrap.min.css' %}">
<!-- Some amazing markup -->
<script src="{% static 'jquery/dist/jquery.min.js' }"><script>
<script src="{% static 'bootstrap/dist/js/bootstrap.js' }"><script>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-node-assets-0.9.6.tar.gz
.
File metadata
- Download URL: django-node-assets-0.9.6.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 241c212565dc2f923f0f1321bcd34fb3cf3f2ef28c25b72ce76713b137f79fce |
|
MD5 | 8f2271d2e60d728734a550d76161d34d |
|
BLAKE2b-256 | 9fa10d66267a19a570255da215cca42d5002ce1e0d29a39098ed94da9fc9ef68 |
File details
Details for the file django_node_assets-0.9.6-py3-none-any.whl
.
File metadata
- Download URL: django_node_assets-0.9.6-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8470247f633a7fa0219315664ab1342b6e2b22663ab12c67a217700f4ba22584 |
|
MD5 | e145efe49061a6a38dc8ee21d4d21d02 |
|
BLAKE2b-256 | 2004355997d9c5cbb28b1fb97b0cef7d51fc8cb1eb173caa91e4d08ae14cf0c6 |