Go for a more generic js bundling architecture

* Don't tie the output name to webpack itself
* Don't call js bundling webpack in python code
* Make the doc more generic about js bundling
This commit is contained in:
2024-11-18 15:36:05 +01:00
committed by Bartuccio Antoine
parent 3db1f592e2
commit 7b41051d0d
56 changed files with 73 additions and 73 deletions

View File

@ -7,11 +7,11 @@ from django.contrib.staticfiles.management.commands.collectstatic import (
)
from staticfiles.apps import GENERATED_ROOT, IGNORE_PATTERNS_SCSS
from staticfiles.processors import OpenApi, Scss, Webpack
from staticfiles.processors import JSBundler, OpenApi, Scss
class Command(CollectStatic):
"""Integrate webpack and css compilation to collectstatic"""
"""Integrate js bundling and css compilation to collectstatic"""
def add_arguments(self, parser):
super().add_arguments(parser)
@ -50,8 +50,8 @@ class Command(CollectStatic):
return Path(location)
Scss.compile(self.collect_scss())
OpenApi.compile() # This needs to be prior to webpack
Webpack.compile()
OpenApi.compile() # This needs to be prior to javascript bundling
JSBundler.compile()
collected = super().collect()

View File

@ -6,19 +6,19 @@ from django.contrib.staticfiles.management.commands.runserver import (
)
from django.utils.autoreload import DJANGO_AUTORELOAD_ENV
from staticfiles.processors import OpenApi, Webpack
from staticfiles.processors import JSBundler, OpenApi
class Command(Runserver):
"""Light wrapper around default runserver that integrates webpack auto bundling."""
"""Light wrapper around default runserver that integrates javascirpt auto bundling."""
def run(self, **options):
# OpenApi generation needs to be before webpack
# OpenApi generation needs to be before the bundler
OpenApi.compile()
# Only run webpack server when debug is enabled
# Only run the bundling server when debug is enabled
# Also protects from re-launching the server if django reloads it
if os.environ.get(DJANGO_AUTORELOAD_ENV) is None and settings.DEBUG:
with Webpack.runserver():
with JSBundler.runserver():
super().run(**options)
return
super().run(**options)