diff --git a/.circleci/config.yml b/.circleci/config.yml
index 15a9b689..05a54546 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -3,29 +3,72 @@ workflows:
version: 2
test:
jobs:
- - test-3.4-18
- - test-3.4-19
- - test-3.4-110
- - test-3.4-111
-
- - test-3.5-18
- - test-3.5-19
- - test-3.5-110
- - test-3.5-111
-
- - test-3.6-18
- - test-3.6-19
- - test-3.6-110
- - test-3.6-111
+ - test-3.5-20
+ - test-3.5-21
+ - test-3.5-22
+
+ - test-3.6-20
+ - test-3.6-21
- test-3.6-22
+ - test-3.6-30
+ - test-3.6-31
+ - test-3.6-32
- - test-3.7-18
- - test-3.7-19
- - test-3.7-110
- - test-3.7-111
+ - test-3.7-20
+ - test-3.7-21
- test-3.7-22
+ - test-3.7-30
+ - test-3.7-31
+ - test-3.7-32
+ - test-3.8-20
+ - test-3.8-21
- test-3.8-22
+ - test-3.8-30
+ - test-3.8-31
+ - test-3.8-32
+
+ - test-3.9-20
+ - test-3.9-21
+ - test-3.9-22
+ - test-3.9-30
+ - test-3.9-31
+ - test-3.9-32
+
+ - done:
+ requires:
+ - test-3.5-20
+ - test-3.5-21
+ - test-3.5-22
+
+ - test-3.6-20
+ - test-3.6-21
+ - test-3.6-22
+ - test-3.6-30
+ - test-3.6-31
+ - test-3.6-32
+
+ - test-3.7-20
+ - test-3.7-21
+ - test-3.7-22
+ - test-3.7-30
+ - test-3.7-31
+ - test-3.7-32
+
+ - test-3.8-20
+ - test-3.8-21
+ - test-3.8-22
+ - test-3.8-30
+ - test-3.8-31
+ - test-3.8-32
+
+ - test-3.9-20
+ - test-3.9-21
+ - test-3.9-22
+ - test-3.9-30
+ - test-3.9-31
+ - test-3.9-32
+
jobs:
base: &test-template
docker:
@@ -71,121 +114,183 @@ jobs:
source venv/bin/activate
cd tests
coverage run --source=webpack_loader manage.py test
- test-3.4-18:
- <<: *test-template
- docker:
- - image: circleci/python:3.4-stretch-node
- environment:
- DJANGO_VERSION: "18"
- test-3.4-19:
- <<: *test-template
- docker:
- - image: circleci/python:3.4-stretch-node
- environment:
- DJANGO_VERSION: "19"
- test-3.4-110:
- <<: *test-template
- docker:
- - image: circleci/python:3.4-stretch-node
- environment:
- DJANGO_VERSION: "110"
- test-3.4-111:
- <<: *test-template
- docker:
- - image: circleci/python:3.4-stretch-node
- environment:
- DJANGO_VERSION: "111"
+ coveralls
+ environment:
+ COVERALLS_PARALLEL: 1
- test-3.5-18:
+ test-3.5-20:
<<: *test-template
docker:
- image: circleci/python:3.5-stretch-node
environment:
- DJANGO_VERSION: "18"
- test-3.5-19:
+ DJANGO_VERSION: "20"
+ test-3.5-21:
<<: *test-template
docker:
- image: circleci/python:3.5-stretch-node
environment:
- DJANGO_VERSION: "19"
- test-3.5-110:
+ DJANGO_VERSION: "21"
+ test-3.5-22:
<<: *test-template
docker:
- image: circleci/python:3.5-stretch-node
environment:
- DJANGO_VERSION: "110"
- test-3.5-111:
+ DJANGO_VERSION: "22"
+
+ test-3.6-20:
<<: *test-template
docker:
- - image: circleci/python:3.5-stretch-node
+ - image: circleci/python:3.6-stretch-node
environment:
- DJANGO_VERSION: "111"
-
- test-3.6-18:
+ DJANGO_VERSION: "20"
+ test-3.6-21:
<<: *test-template
docker:
- image: circleci/python:3.6-stretch-node
environment:
- DJANGO_VERSION: "18"
- test-3.6-19:
+ DJANGO_VERSION: "21"
+ test-3.6-22:
<<: *test-template
docker:
- image: circleci/python:3.6-stretch-node
environment:
- DJANGO_VERSION: "19"
- test-3.6-110:
+ DJANGO_VERSION: "22"
+ test-3.6-30:
<<: *test-template
docker:
- image: circleci/python:3.6-stretch-node
environment:
- DJANGO_VERSION: "110"
- test-3.6-111:
+ DJANGO_VERSION: "30"
+ test-3.6-31:
<<: *test-template
docker:
- image: circleci/python:3.6-stretch-node
environment:
- DJANGO_VERSION: "111"
- test-3.6-22:
+ DJANGO_VERSION: "31"
+ test-3.6-32:
<<: *test-template
docker:
- image: circleci/python:3.6-stretch-node
environment:
- DJANGO_VERSION: "22"
+ DJANGO_VERSION: "32"
- test-3.7-18:
+ test-3.7-20:
<<: *test-template
docker:
- image: circleci/python:3.7-stretch-node
environment:
- DJANGO_VERSION: "18"
- test-3.7-19:
+ DJANGO_VERSION: "20"
+ test-3.7-21:
<<: *test-template
docker:
- image: circleci/python:3.7-stretch-node
environment:
- DJANGO_VERSION: "19"
- test-3.7-110:
+ DJANGO_VERSION: "21"
+ test-3.7-22:
<<: *test-template
docker:
- image: circleci/python:3.7-stretch-node
environment:
- DJANGO_VERSION: "110"
- test-3.7-111:
+ DJANGO_VERSION: "22"
+ test-3.7-30:
<<: *test-template
docker:
- image: circleci/python:3.7-stretch-node
environment:
- DJANGO_VERSION: "111"
- test-3.7-22:
+ DJANGO_VERSION: "30"
+ test-3.7-31:
<<: *test-template
docker:
- image: circleci/python:3.7-stretch-node
environment:
- DJANGO_VERSION: "22"
+ DJANGO_VERSION: "31"
+ test-3.7-32:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.7-stretch-node
+ environment:
+ DJANGO_VERSION: "32"
+ test-3.8-20:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.8-buster-node
+ environment:
+ DJANGO_VERSION: "20"
+ test-3.8-21:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.8-buster-node
+ environment:
+ DJANGO_VERSION: "21"
test-3.8-22:
<<: *test-template
docker:
- image: circleci/python:3.8-buster-node
environment:
DJANGO_VERSION: "22"
+ test-3.8-30:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.8-buster-node
+ environment:
+ DJANGO_VERSION: "30"
+ test-3.8-31:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.8-buster-node
+ environment:
+ DJANGO_VERSION: "31"
+ test-3.8-32:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.8-buster-node
+ environment:
+ DJANGO_VERSION: "32"
+
+ test-3.9-20:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.9-buster-node
+ environment:
+ DJANGO_VERSION: "20"
+ test-3.9-21:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.9-buster-node
+ environment:
+ DJANGO_VERSION: "21"
+ test-3.9-22:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.9-buster-node
+ environment:
+ DJANGO_VERSION: "22"
+ test-3.9-30:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.9-buster-node
+ environment:
+ DJANGO_VERSION: "30"
+ test-3.9-31:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.9-buster-node
+ environment:
+ DJANGO_VERSION: "31"
+ test-3.9-32:
+ <<: *test-template
+ docker:
+ - image: circleci/python:3.9-buster-node
+ environment:
+ DJANGO_VERSION: "32"
+
+ done:
+ docker:
+ - image: circleci/python:3.9-buster-node
+ steps:
+ - run:
+ name: Finish Coveralls
+ command: |
+ pip install coveralls
+ coveralls --finish
diff --git a/.gitignore b/.gitignore
index 5b697119..e6e344be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
venv/
+*.sqlite3
# auto generated
README.rst
@@ -70,7 +71,7 @@ examples/**/ve/
examples/**/venv/
examples/**/node_modules/
examples/**/assets/bundles/
-examples/**/assets/webpack-stats.json
+examples/**/webpack-stats.json
tests/ve/
tests/ve3/
@@ -78,6 +79,7 @@ tests/venv/
tests/venv3/
tests/node_modules/
tests/assets/bundles/
+tests/assets/django_webpack_loader_bundles/
tests/webpack-stats.json
tests/webpack-stats-app2.json
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ecc44fc4..bf2e8bb4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,29 @@ For more general information, view the [readme](README.md).
Releases are added to the
[github release page](https://github.com/ezhome/django-webpack-loader/releases).
+## [1.3.0] -- 2021-08-30
+
+- Add option for rel="preload" in JS/CSS tags #203
+- Add option for extension appending in the url files #135
+- Fixes RemovedInDjango41Warning #290
+- Applies IGNORE setting before checking assets #286
+- Removed type from link and script tags per #152
+
+NOTE: Skipped version 1.2.0 to match `webpack-bundle-tracker` version
+
+
+## [1.1.0] -- 2021-06-18
+
+- Added compatibility with `webpack-bundle-tracker@1.1.0`
+- Removes bower references in project
+- Fix jinja configuration example in README.md
+
+## [1.0.0] -- 2021-05-12
+
+- Added support for custom loader classes
+- Added compatibility with `webpack-bundle-tracker@1.0.0-alpha.1`
+- Updated and corrected examples
+- Updated Python and Django supported versions on tests
## [0.6.0] -- 2018-02-22
- Added support for 'Access-Control-Allow-Origin' header
diff --git a/Makefile b/Makefile
index 730d210d..7f1cc335 100644
--- a/Makefile
+++ b/Makefile
@@ -27,9 +27,9 @@ install:
@$(ENV)/bin/pip install $(requirements)
publish: build
- @echo "Publishing to pypi..."
+ @echo "Publishing to $(REPOSITORY)..."
@$(ENV)/bin/twine upload -r $(REPOSITORY) dist/*
register:
- @echo "Registering package on pypi..."
+ @echo "Registering package on $(REPOSITORY)..."
@$(ENV)/bin/twine register -r $(REPOSITORY)
diff --git a/README.md b/README.md
index 6f35da1b..c60a89df 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,11 @@
-# django-webpack-loader
+# django-webpack-loader for gzip
-[](https://gitter.im/owais/django-webpack-loader?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
-[](https://circleci.com/gh/owais/django-webpack-loader/tree/master)
-[](https://coveralls.io/github/owais/django-webpack-loader?branch=master)
+Different from the original repository, it appends an extension in the creation of the tags (as .gzip). The append is also dynamic, and can be done for css or js
+
+[](https://circleci.com/gh/django-webpack/django-webpack-loader/tree/master)
+[](https://coveralls.io/github/django-webpack/django-webpack-loader?branch=master)
+
+
@@ -19,7 +22,7 @@ A [changelog](CHANGELOG.md) is also available.
## Compatibility
-Test 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.
+Test cases cover Django>=2.0 on Python>=3.5. 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.
## Install
@@ -32,6 +35,14 @@ pip install django-webpack-loader
+## Migrating from version < 1.0.0
+
+In order to use `django-webpack-loader>=1.0.0`, you must ensure that `webpack-bundle-tracker@1.0.0` is being used on the JavaScript side. It's recommended that you always keep at least minor version parity across both packages, for full compatibility.
+
+This is necessary because the formatting of `webpack-stats.json` that `webpack-bundle-tracker` outputs has changed starting at version `1.0.0-alpha.1`. Starting at `django-webpack-loader==1.0.0`, this is the only formatting accepted here, meaning that other versions of that package don't output compatible files anymore, thereby breaking compatibility with older `webpack-bundle-tracker` releases.
+
+
+
## Configuration
@@ -124,7 +135,7 @@ WEBPACK_LOADER = {
If the bundle generates a file called `main-cf4b5fab6e00a404e0c7.js` and your STATIC_URL is `/static/`, then the `',
- '']
+['',
+ '']
```
## How to use in Production
@@ -389,12 +441,12 @@ If you need to output your assets in a jinja template we provide a Jinja2 extens
To install the extension add it to the django_jinja `TEMPLATES` configuration in the `["OPTIONS"]["extension"]` list.
```python
+from django_jinja.builtins import DEFAULT_EXTENSIONS
TEMPLATES = [
{
"BACKEND": "django_jinja.backend.Jinja2",
"OPTIONS": {
- "extensions": [
- "django_jinja.builtins.extensions.DjangoFiltersExtension",
+ "extensions": DEFAULT_EXTENSIONS + [
"webpack_loader.contrib.jinja2ext.WebpackExtension",
],
}
@@ -413,3 +465,14 @@ Then in your base jinja template:
Enjoy your webpack with django :)
+
+# Alternatives to Django-Webpack-Loader
+
+_Below are known projects that attempt to solve the same problem:_
+
+Note that these projects have not been vetted or reviewed in any way by me.
+These are not recommendation.
+Anyone can add their project to this by sending a PR.
+
+* [Django Manifest Loader](https://github.com/shonin/django-manifest-loader)
+* [Python Webpack Boilerplate](https://github.com/AccordBox/python-webpack-boilerplate)
diff --git a/examples/code-splitting/app/asgi.py b/examples/code-splitting/app/asgi.py
new file mode 100644
index 00000000..895c0e06
--- /dev/null
+++ b/examples/code-splitting/app/asgi.py
@@ -0,0 +1,16 @@
+"""
+ASGI config for app project.
+
+It exposes the ASGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
+"""
+
+import os
+
+from django.core.asgi import get_asgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
+
+application = get_asgi_application()
diff --git a/examples/code-splitting/app/settings.py b/examples/code-splitting/app/settings.py
index ff00e19b..923969f1 100644
--- a/examples/code-splitting/app/settings.py
+++ b/examples/code-splitting/app/settings.py
@@ -1,26 +1,27 @@
"""
Django settings for app project.
-Generated by 'django-admin startproject' using Django 1.8.2.
+Generated by 'django-admin startproject' using Django 3.2.2.
For more information on this file, see
-https://docs.djangoproject.com/en/1.8/topics/settings/
+https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
-https://docs.djangoproject.com/en/1.8/ref/settings/
+https://docs.djangoproject.com/en/3.2/ref/settings/
"""
-# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+from pathlib import Path
import os
-BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+# Build paths inside the project like this: BASE_DIR / 'subdir'.
+BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
-# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
+# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
-SECRET_KEY = '+g25&y9i+-6_z$$z!ov$l2s%b#0kcmnx)n7y*2_ehy-w011p#k'
+SECRET_KEY = 'django-insecure-&24ubb46zaej*fd9jz1^mw1t0)-@zd9g74f!hcs1a48-7loo0r'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
@@ -30,34 +31,32 @@
# Application definition
-INSTALLED_APPS = (
+INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
- 'app',
'webpack_loader',
-)
+]
-MIDDLEWARE_CLASSES = (
+MIDDLEWARE = [
+ 'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
- 'django.middleware.security.SecurityMiddleware',
-)
+]
ROOT_URLCONF = 'app.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
- 'DIRS': [],
+ 'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
@@ -74,18 +73,18 @@
# Database
-# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
+# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
- 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+ 'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Internationalization
-# https://docs.djangoproject.com/en/1.8/topics/i18n/
+# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
@@ -99,7 +98,7 @@
# Static files (CSS, JavaScript, Images)
-# https://docs.djangoproject.com/en/1.8/howto/static-files/
+# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
@@ -113,3 +112,8 @@
'STATS_FILE': os.path.join(BASE_DIR, 'webpack-stats.json')
}
}
+
+# Default primary key field type
+# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
+
+DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
diff --git a/examples/code-splitting/app/urls.py b/examples/code-splitting/app/urls.py
index b1ad5f06..00663ff3 100644
--- a/examples/code-splitting/app/urls.py
+++ b/examples/code-splitting/app/urls.py
@@ -1,25 +1,23 @@
"""app URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
- https://docs.djangoproject.com/en/1.8/topics/http/urls/
+ https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
- 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
- 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
- 1. Add an import: from blog import urls as blog_urls
- 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
+ 1. Import the include() function: from django.urls import include, path
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
-from django.conf.urls import include, url
from django.contrib import admin
+from django.urls import path
from django.views.generic import TemplateView
-
-
urlpatterns = [
- url(r'^$', TemplateView.as_view(template_name='home.html'), name='home'),
- url(r'^admin/', include(admin.site.urls)),
+ path('admin/', admin.site.urls),
+ path('', TemplateView.as_view(template_name='home.html'), name='home'),
]
diff --git a/examples/code-splitting/app/views.py b/examples/code-splitting/app/views.py
deleted file mode 100644
index 955db581..00000000
--- a/examples/code-splitting/app/views.py
+++ /dev/null
@@ -1 +0,0 @@
-from django.views.generic.base import TemplateView
diff --git a/examples/code-splitting/app/wsgi.py b/examples/code-splitting/app/wsgi.py
index ea9ff951..768c6e41 100644
--- a/examples/code-splitting/app/wsgi.py
+++ b/examples/code-splitting/app/wsgi.py
@@ -4,13 +4,13 @@
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
-https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
+https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings")
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'app.settings')
application = get_wsgi_application()
diff --git a/examples/code-splitting/assets/js/app.jsx b/examples/code-splitting/assets/js/app.jsx
index c729eb78..8ef06334 100644
--- a/examples/code-splitting/assets/js/app.jsx
+++ b/examples/code-splitting/assets/js/app.jsx
@@ -1,7 +1,7 @@
-var React = require('react');
+import React from 'react';
-module.exports = React.createClass({
- render: function(){
- return