{ "info": { "author": "Ali Farouk", "author_email": "alifarouk102@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5" ], "description": "# django-webpack-loader\n\n[![Join the chat at https://gitter.im/owais/django-webpack-loader](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/owais/django-webpack-loader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n[![Build Status](https://travis-ci.org/owais/django-webpack-loader.svg?branch=master)](https://travis-ci.org/owais/django-webpack-loader)\n[![Coverage Status](https://coveralls.io/repos/owais/django-webpack-loader/badge.svg?branch=master&service=github)](https://coveralls.io/github/owais/django-webpack-loader?branch=master)\n\n
\n\nRead http://owaislone.org/blog/webpack-plus-reactjs-and-django/ for a detailed step by step guide on setting up webpack with django using this library.\n\nUse webpack to generate your static bundles without django's staticfiles or opaque wrappers.\n\nDjango webpack loader consumes the output generated by [webpack-bundle-tracker](https://github.com/owais/webpack-bundle-tracker) and lets you use the generated bundles in django.\n\nA [changelog](CHANGELOG.md) is also available.\n\n## Compatibility\n\nTest cases cover Django>=1.6 on Python 2.7 and Python>=3.4. 100% code coverage is the target so we can be sure everything works anytime. It should probably work on older version of django as well but the package does not ship any test cases for them.\n\n## Install\n\n```bash\nnpm install --save-dev webpack-bundle-tracker\n\npip install django4-webpack-loader\n```\n\n
\n\n## Configuration\n\n
\n\n### Assumptions\n\nAssuming `BASE_DIR` in settings refers to the root of your django app.\n\n```python\nimport sys\nimport os\n\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\n```\n\n
\n\nAssuming `assets/` is in `settings.STATICFILES_DIRS` like\n\n```python\nSTATICFILES_DIRS = (\n os.path.join(BASE_DIR, 'assets'),\n)\n```\n\n
\n\nAssuming your webpack config lives at `./webpack.config.js` and looks like this\n\n```javascript\nvar path = require(\"path\");\nvar webpack = require(\"webpack\");\nvar BundleTracker = require(\"webpack-bundle-tracker\");\n\nmodule.exports = {\n context: __dirname,\n entry: \"./assets/js/index\",\n output: {\n path: path.resolve(\"./assets/webpack_bundles/\"),\n filename: \"[name]-[hash].js\"\n },\n\n plugins: [new BundleTracker({ filename: \"./webpack-stats.json\" })]\n};\n```\n\n
\n\n### Default Configuration\n\n```python\nWEBPACK_LOADER = {\n 'DEFAULT': {\n 'CACHE': not DEBUG,\n 'BUNDLE_DIR_NAME': 'webpack_bundles/', # must end with slash\n 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json'),\n 'POLL_INTERVAL': 0.1,\n 'TIMEOUT': None,\n 'IGNORE': ['.+\\.hot-update.js', '.+\\.map']\n }\n}\n```\n\n
\n\n#### CACHE\n\n```python\nWEBPACK_LOADER = {\n 'DEFAULT': {\n 'CACHE': not DEBUG\n }\n}\n```\n\nWhen `CACHE` is set to True, webpack-loader will read the stats file only once and cache the result. This means web workers need to be restarted in order to pick up any changes made to the stats files.\n\n
\n\n#### BUNDLE_DIR_NAME\n\n```python\nWEBPACK_LOADER = {\n 'DEFAULT': {\n 'BUNDLE_DIR_NAME': 'bundles/' # end with slash\n }\n}\n```\n\n`BUNDLE_DIR_NAME` refers to the dir in which webpack outputs the bundles. It should not be the full path. If `./assets` is one of your static dirs and webpack generates the bundles in `./assets/output/bundles/`, then `BUNDLE_DIR_NAME` should be `output/bundles/`.\n\nIf the bundle generates a file called `main-cf4b5fab6e00a404e0c7.js` and your STATIC_URL is `/static/`, then the `',\n '']\n```\n\n## How to use in Production\n\n**It is up to you**. There are a few ways to handle this. I like to have slightly separate configs for production and local. I tell git to ignore my local stats + bundle file but track the ones for production. Before pushing out newer version to production, I generate a new bundle using production config and commit the new stats file and bundle. I store the stats file and bundles in a directory that is added to the `STATICFILES_DIR`. This gives me integration with collectstatic for free. The generated bundles are automatically collected to the target directory and synched to S3.\n\n`./webpack_production.config.js`\n\n```javascript\nvar config = require(\"./webpack.config.js\");\nvar BundleTracker = require(\"webpack-bundle-tracker\");\n\nconfig.output.path = require(\"path\").resolve(\"./assets/dist\");\n\nconfig.plugins = [new BundleTracker({ filename: \"./webpack-stats-prod.json\" })];\n\n// override any other settings here like using Uglify or other things that make sense for production environments.\n\nmodule.exports = config;\n```\n\n`settings.py`\n\n```python\nif not DEBUG:\n WEBPACK_LOADER.update({\n 'BUNDLE_DIR_NAME': 'dist/',\n 'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats-prod.json')\n })\n```\n\n

\n\nYou can also simply generate the bundles on the server before running collectstatic if that works for you.\n\n## Extra\n\n### Jinja2 Configuration\n\nIf you need to output your assets in a jinja template we provide a Jinja2 extension that's compatible with the [Django Jinja](https://github.com/niwinz/django-jinja) module and Django 1.8.\n\nTo install the extension add it to the django_jinja `TEMPLATES` configuration in the `[\"OPTIONS\"][\"extension\"]` list.\n\n```python\nTEMPLATES = [\n {\n \"BACKEND\": \"django_jinja.backend.Jinja2\",\n \"OPTIONS\": {\n \"extensions\": [\n \"django_jinja.builtins.extensions.DjangoFiltersExtension\",\n \"webpack_loader.contrib.jinja2ext.WebpackExtension\",\n ],\n }\n }\n]\n```\n\nThen in your base jinja template:\n\n```HTML\n{{ render_bundle('main') }}\n```\n\n---\n\n
\n\nEnjoy your webpack with django :)\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/alihazemfarouk/django-webpack-loader", "keywords": "django,webpack,assets", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-webpack4-loader", "package_url": "https://pypi.org/project/django-webpack4-loader/", "platform": "", "project_url": "https://pypi.org/project/django-webpack4-loader/", "project_urls": { "Homepage": "https://github.com/alihazemfarouk/django-webpack-loader" }, "release_url": "https://pypi.org/project/django-webpack4-loader/0.0.5/", "requires_dist": null, "requires_python": "", "summary": "Transparently use webpack with django. Forked from https://github.com/scdekov/django-webpack-loader", "version": "0.0.5" }, "last_serial": 4775776, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "b7161dea7a503a128a76339f45c3f39d", "sha256": "2cd1ea199c066b00c857f89269ff12686f9c4b1d8e2c23de7a26d2ee651233eb" }, "downloads": -1, "filename": "django_webpack4_loader-0.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b7161dea7a503a128a76339f45c3f39d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13900, "upload_time": "2019-01-08T13:52:40", "url": "https://files.pythonhosted.org/packages/b5/de/89b13ade29bb58e9546597353eaca3c20b7796c22406fa6a739d20d8693b/django_webpack4_loader-0.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "3f15f734bae5e9e20c186cef0505f306", "sha256": "4a04c3a1decf0154af707e674fa870b106d16432d1526510db4e5d7ef5613361" }, "downloads": -1, "filename": "django-webpack4-loader-0.0.1.tar.gz", "has_sig": false, "md5_digest": "3f15f734bae5e9e20c186cef0505f306", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10977, "upload_time": "2019-01-08T13:52:42", "url": "https://files.pythonhosted.org/packages/06/f2/6a01a060a74bd5b275450d8d0affbac3e23786a634e1c447a873fa759af9/django-webpack4-loader-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "481ae82cc4b02d86ee7af8379ae4609d", "sha256": "f81466aef7d9f04a6e406a6b3c953cf38bf689b333dcc2339eef10f7f8227a52" }, "downloads": -1, "filename": "django_webpack4_loader-0.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "481ae82cc4b02d86ee7af8379ae4609d", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17647, "upload_time": "2019-01-09T11:10:28", "url": "https://files.pythonhosted.org/packages/03/ff/58172a803e27325f680bce184c0bb2d227bf2b379d725c9bcee40c162060/django_webpack4_loader-0.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ffe8d645d7cd801b1863a12753c92a13", "sha256": "6ef51c12d2cdecc8eeb738ecaf11a041710f591fbdebfe0d30d97b9bb4f5c93a" }, "downloads": -1, "filename": "django-webpack4-loader-0.0.2.tar.gz", "has_sig": false, "md5_digest": "ffe8d645d7cd801b1863a12753c92a13", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11050, "upload_time": "2019-01-09T11:10:30", "url": "https://files.pythonhosted.org/packages/c2/45/448d01d8895162c533a63c2bfb6f38f508faa363402c4bb518682a7bb76e/django-webpack4-loader-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "09fd5221a9dfbcb9c115564b3b491d82", "sha256": "93daac0d73d65192305e61ca984c002f19a26abfd6b2285fd149c34a221ba23e" }, "downloads": -1, "filename": "django_webpack4_loader-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "09fd5221a9dfbcb9c115564b3b491d82", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17654, "upload_time": "2019-01-09T11:31:52", "url": "https://files.pythonhosted.org/packages/56/f8/3d2058e65acbe98bdfd17805d76e152f49fc6daccbc3a08f6b379d4c8d78/django_webpack4_loader-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "945a1b6ff878cc72d587a92f45738f45", "sha256": "bb6d6b2004518c9cf01789e1ef77b9db81e94f178fe3abc5a5e5b0a7427c013e" }, "downloads": -1, "filename": "django-webpack4-loader-0.0.3.tar.gz", "has_sig": false, "md5_digest": "945a1b6ff878cc72d587a92f45738f45", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11043, "upload_time": "2019-01-09T11:31:54", "url": "https://files.pythonhosted.org/packages/84/c6/22ff83825ba83c3564e628d6c4097048669bf17aec927c908829e3f71e63/django-webpack4-loader-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "452daaf10fe58308845681b99072a390", "sha256": "92a14407dcae1f5464291a8e69c7f3f214149c74239ebab0984895d609ca1881" }, "downloads": -1, "filename": "django_webpack4_loader-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "452daaf10fe58308845681b99072a390", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17776, "upload_time": "2019-01-09T12:09:37", "url": "https://files.pythonhosted.org/packages/24/7f/bad629379248d1d53e0c22d505f1e29de4d87e7d5fc1a6071d4d9fc82ebb/django_webpack4_loader-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6a9523b8c7236413ffacb304e5b820e5", "sha256": "045ef656a42a7aaab82649e75a2e8793a246c4adaab455daea0d474b816849f3" }, "downloads": -1, "filename": "django-webpack4-loader-0.0.4.tar.gz", "has_sig": false, "md5_digest": "6a9523b8c7236413ffacb304e5b820e5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11144, "upload_time": "2019-01-09T12:09:39", "url": "https://files.pythonhosted.org/packages/40/2b/b40d724c7ce1bf5f125a9bea7523e48158040845e9e5d258f4610f3ab2cb/django-webpack4-loader-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "37c8b3e1742a03d0ea2ebcf3f28ada4e", "sha256": "be90257041170f39c025ff674c9064569c9303b464536488b6a6cedd8e3d28be" }, "downloads": -1, "filename": "django_webpack4_loader-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "37c8b3e1742a03d0ea2ebcf3f28ada4e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17777, "upload_time": "2019-02-03T21:41:38", "url": "https://files.pythonhosted.org/packages/4e/4d/29da8d9e1fef86262126c2b8a82f8fd24570d74b229a544ee4b0068ed28d/django_webpack4_loader-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e111c57e4c1bd004a44a7f302952271a", "sha256": "baa043c4601ed763d161490e2888cf6aa93a2fd9b60681e6b19e35dc7fcb155d" }, "downloads": -1, "filename": "django-webpack4-loader-0.0.5.tar.gz", "has_sig": false, "md5_digest": "e111c57e4c1bd004a44a7f302952271a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11155, "upload_time": "2019-02-03T21:41:41", "url": "https://files.pythonhosted.org/packages/10/ff/a951492aa57a4c09b0e2f57f4d67b931a62af3c5405657a6c934b78ea5c8/django-webpack4-loader-0.0.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "37c8b3e1742a03d0ea2ebcf3f28ada4e", "sha256": "be90257041170f39c025ff674c9064569c9303b464536488b6a6cedd8e3d28be" }, "downloads": -1, "filename": "django_webpack4_loader-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "37c8b3e1742a03d0ea2ebcf3f28ada4e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 17777, "upload_time": "2019-02-03T21:41:38", "url": "https://files.pythonhosted.org/packages/4e/4d/29da8d9e1fef86262126c2b8a82f8fd24570d74b229a544ee4b0068ed28d/django_webpack4_loader-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e111c57e4c1bd004a44a7f302952271a", "sha256": "baa043c4601ed763d161490e2888cf6aa93a2fd9b60681e6b19e35dc7fcb155d" }, "downloads": -1, "filename": "django-webpack4-loader-0.0.5.tar.gz", "has_sig": false, "md5_digest": "e111c57e4c1bd004a44a7f302952271a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11155, "upload_time": "2019-02-03T21:41:41", "url": "https://files.pythonhosted.org/packages/10/ff/a951492aa57a4c09b0e2f57f4d67b931a62af3c5405657a6c934b78ea5c8/django-webpack4-loader-0.0.5.tar.gz" } ] }