Integrate django with yarnpkg
Project description
Easy way to use yarnpkg with your Django project.
This is a fork of django-bower <https://github.com/nvbn/django-bower> by Vladimir Iakovlev.
Read full documentation on read-the-docs.
Installation
Install django-yarnpkg package:
pip install django-yarnpkg
Add django-bower to INSTALLED_APPS in your settings:
'django_yarnpkg',
Add staticfinder to STATICFILES_FINDERS:
'django_yarnpkg.finders.NodeModulesFinder',
Specify path to components root (you need to use an absolute path):
NODE_MODULES_ROOT = os.path.join(BASE_DIR, 'node_modules')
If you need, you can manually set the path to yarnpkg:
YARN_PATH = '/usr/bin/yarnpkg'
You can see an example settings file in example project.
Usage
Specify YARN_INSTALLED_APPS in settings, like:
YARN_INSTALLED_APPS = (
'bootstrap@^4.4.1',
'underscore@^1.6.1',
)
Download yarn packages with the management command:
./manage.py yarn install
Add scripts in the template, like:
{% load static %}
<script type="text/javascript" src='{% static 'jquery/dist/jquery.js' %}'></script>
In production you need to call yarnpkg install before collectstatic:
./manage.py yarn install
./manage.py collectstatic
If you need to pass arguments to yarnpkg, like –flat, use:
./manage.py yarn install -- --flat
You can call yarnpkg commands like info and update with:
./manage.py yarn info backbone
./manage.py yarn update
Python 3 support
django-yarnpkg supports python 3.3+
Project details
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
Hashes for django_yarnpkg-6.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef6bb39eb95f1226965d4e8e5455d14145596bf35c21ff4fc210c4ede32860f4 |
|
MD5 | cfcd2f8d2b06757af5d36c5fe0028699 |
|
BLAKE2b-256 | 1ff6cd840da9b853c1557ec433fe8dce6e8b5cf15006a16e9fcb8eebe335299f |