django-node-assets


Namedjango-node-assets JSON
Version 0.9.14 PyPI version JSON
download
home_pageNone
SummaryThe Django application that allows to install and serve assets via Node.js package manager infrastructure.
upload_time2024-06-27 22:29:14
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseMIT License Copyright (c) 2023 Andrey Butenko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords django assets staticfiles node.js npm package.json
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ##################
Django-node-assets
##################

.. image:: https://badge.fury.io/py/django-node-assets.svg
    :target: https://badge.fury.io/py/django-node-assets

.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336
    :target: https://pycqa.github.io/isort/

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black

.. image:: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml/badge.svg
    :target: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml

|

The Django application that allows to install and to 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
------------

.. code:: bash

    $ pip install django-node-assets

Configuration
-------------

Add 'django_node_assets' to your INSTALLED_APPS:

.. code:: python

    INSTALLED_APPS = [
        ...
        'django_node_assets',
    ]

Add NodeModulesFinder to STATICFILES_FINDERS:

.. code:: python

    STATICFILES_FINDERS = [
        'django.contrib.staticfiles.finders.FileSystemFinder',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
        'django_node_assets.finders.NodeModulesFinder',
    ]

Specify absolute path to the package.json file:

.. code:: python

    NODE_PACKAGE_JSON = '/var/assets/package.json'

.. note::

    A package.json must have the "dependencies" section and look like:

    .. code:: json

        {
            "dependencies": {
                "jquery": "^3.2.1",
                "bootstrap": "^3.3.5",
            }
        }

    Details here: https://docs.npmjs.com/files/package.json#dependencies


Specify the absolute path to a directory where the **npminstall** management command will install assets:

.. code:: python

    NODE_MODULES_ROOT = '/var/assets/node_modules'

.. note::

    A base dir must be called **node_modules**.

Override path to the node package manager executable (optional)

.. code:: python

    NODE_PACKAGE_MANAGER_EXECUTABLE = '/usr/local/bin/npm'

.. note::

    The node package manager must be already installed in your system.

Override options of the node package manager install command (optional)

.. code:: python

    NODE_PACKAGE_MANAGER_INSTALL_OPTIONS = ['--dry-run']

Defaults to **--no-package-lock**, **--production**.

Usage
-----

Call the **npminstall** management command to install dependencies specified in the package.json

.. code:: bash

    $ python manage.py npminstall

Use Django`s static template tag to link installed assets

.. code:: html

    {% 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>

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-node-assets",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django, assets, staticfiles, Node.js, npm, package.json",
    "author": null,
    "author_email": "Andrey Butenko <whitespysoftware@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/86/0e/7c7e10db716883008be9685c642449939b75b1b76eaf29f60da663bfde74/django_node_assets-0.9.14.tar.gz",
    "platform": null,
    "description": "##################\nDjango-node-assets\n##################\n\n.. image:: https://badge.fury.io/py/django-node-assets.svg\n    :target: https://badge.fury.io/py/django-node-assets\n\n.. image:: https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336\n    :target: https://pycqa.github.io/isort/\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n    :target: https://github.com/psf/black\n\n.. image:: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml/badge.svg\n    :target: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml\n\n|\n\nThe Django application that allows to install and to serve static assets via Node.js package manager infrastructure.\nThe application exposes management command to install dependencies from your **package.json** and several static files\nfinders to find files from installed node packages and exclude metadata of node packages and unwanted files when\nstatic files will be collected via Django`s **collectstatic** management command execution.\n\nFeatures\n--------\n\n- Avoiding vendoring static assets in your repository like jQuery plugins, Bootstrap toolkit, etc\n- Avoiding mess in **STATIC_ROOT** through exclusion node packages` metatadata and unwanted files\n- Installing dependencies by Django`s management command\n\nInstallation\n------------\n\n.. code:: bash\n\n    $ pip install django-node-assets\n\nConfiguration\n-------------\n\nAdd 'django_node_assets' to your INSTALLED_APPS:\n\n.. code:: python\n\n    INSTALLED_APPS = [\n        ...\n        'django_node_assets',\n    ]\n\nAdd NodeModulesFinder to STATICFILES_FINDERS:\n\n.. code:: python\n\n    STATICFILES_FINDERS = [\n        'django.contrib.staticfiles.finders.FileSystemFinder',\n        'django.contrib.staticfiles.finders.AppDirectoriesFinder',\n        'django_node_assets.finders.NodeModulesFinder',\n    ]\n\nSpecify absolute path to the package.json file:\n\n.. code:: python\n\n    NODE_PACKAGE_JSON = '/var/assets/package.json'\n\n.. note::\n\n    A package.json must have the \"dependencies\" section and look like:\n\n    .. code:: json\n\n        {\n            \"dependencies\": {\n                \"jquery\": \"^3.2.1\",\n                \"bootstrap\": \"^3.3.5\",\n            }\n        }\n\n    Details here: https://docs.npmjs.com/files/package.json#dependencies\n\n\nSpecify the absolute path to a directory where the **npminstall** management command will install assets:\n\n.. code:: python\n\n    NODE_MODULES_ROOT = '/var/assets/node_modules'\n\n.. note::\n\n    A base dir must be called **node_modules**.\n\nOverride path to the node package manager executable (optional)\n\n.. code:: python\n\n    NODE_PACKAGE_MANAGER_EXECUTABLE = '/usr/local/bin/npm'\n\n.. note::\n\n    The node package manager must be already installed in your system.\n\nOverride options of the node package manager install command (optional)\n\n.. code:: python\n\n    NODE_PACKAGE_MANAGER_INSTALL_OPTIONS = ['--dry-run']\n\nDefaults to **--no-package-lock**, **--production**.\n\nUsage\n-----\n\nCall the **npminstall** management command to install dependencies specified in the package.json\n\n.. code:: bash\n\n    $ python manage.py npminstall\n\nUse Django`s static template tag to link installed assets\n\n.. code:: html\n\n    {% load static %}\n\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"{% static 'bootstrap/dist/css/bootstrap.min.css' %}\">\n    <!-- Some amazing markup -->\n    <script src=\"{% static 'jquery/dist/jquery.min.js' %}\"></script>\n    <script src=\"{% static 'bootstrap/dist/js/bootstrap.js' %}\"></script>\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Andrey Butenko  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "The Django application that allows to install and serve assets via Node.js package manager infrastructure.",
    "version": "0.9.14",
    "project_urls": {
        "GitHub": "https://github.com/whitespy/django-node-assets"
    },
    "split_keywords": [
        "django",
        " assets",
        " staticfiles",
        " node.js",
        " npm",
        " package.json"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "145b1ccd8fcc24c5c7d655334784a651d59ab81ae11b4875ecf1c80c2a6e57a4",
                "md5": "800130dfa1b18688cd7e384eb4b3d4f6",
                "sha256": "80cbe3d10521808309712b2aa5ef6d69799bbcafef844cf7f223d3c93f405768"
            },
            "downloads": -1,
            "filename": "django_node_assets-0.9.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "800130dfa1b18688cd7e384eb4b3d4f6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6930,
            "upload_time": "2024-06-27T22:29:13",
            "upload_time_iso_8601": "2024-06-27T22:29:13.147129Z",
            "url": "https://files.pythonhosted.org/packages/14/5b/1ccd8fcc24c5c7d655334784a651d59ab81ae11b4875ecf1c80c2a6e57a4/django_node_assets-0.9.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "860e7c7e10db716883008be9685c642449939b75b1b76eaf29f60da663bfde74",
                "md5": "bb078d184ddac261e619412a754a910b",
                "sha256": "d5b5c472136084d533268f52ab77897327863a102e25c81f484aae85eb806987"
            },
            "downloads": -1,
            "filename": "django_node_assets-0.9.14.tar.gz",
            "has_sig": false,
            "md5_digest": "bb078d184ddac261e619412a754a910b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6404,
            "upload_time": "2024-06-27T22:29:14",
            "upload_time_iso_8601": "2024-06-27T22:29:14.979076Z",
            "url": "https://files.pythonhosted.org/packages/86/0e/7c7e10db716883008be9685c642449939b75b1b76eaf29f60da663bfde74/django_node_assets-0.9.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-27 22:29:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "whitespy",
    "github_project": "django-node-assets",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-node-assets"
}
        
Elapsed time: 3.65122s