2024-09-17 21:42:05 +00:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
from django.contrib.staticfiles.apps import StaticFilesConfig
|
|
|
|
|
|
|
|
GENERATED_ROOT = Path(__file__).parent.resolve() / "generated"
|
2024-11-18 14:36:05 +00:00
|
|
|
IGNORE_PATTERNS_BUNDLED = ["bundled/*"]
|
2024-09-17 21:42:05 +00:00
|
|
|
IGNORE_PATTERNS_SCSS = ["*.scss"]
|
2024-10-09 15:30:44 +00:00
|
|
|
IGNORE_PATTERNS_TYPESCRIPT = ["*.ts"]
|
2024-09-17 21:42:05 +00:00
|
|
|
IGNORE_PATTERNS = [
|
|
|
|
*StaticFilesConfig.ignore_patterns,
|
2024-10-09 15:30:44 +00:00
|
|
|
*IGNORE_PATTERNS_TYPESCRIPT,
|
2024-11-18 14:36:05 +00:00
|
|
|
*IGNORE_PATTERNS_BUNDLED,
|
2024-09-17 21:42:05 +00:00
|
|
|
*IGNORE_PATTERNS_SCSS,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
2024-10-15 09:36:26 +00:00
|
|
|
# We override the original staticfiles app according to
|
|
|
|
# https://docs.djangoproject.com/en/4.2/ref/contrib/staticfiles/#customizing-the-ignored-pattern-list
|
|
|
|
# However, this is buggy and requires us
|
|
|
|
# to have an exact naming of the class like this to be detected
|
|
|
|
# Also, it requires to create all commands in management/commands again
|
|
|
|
# or they don't get detected by django
|
2024-09-17 21:42:05 +00:00
|
|
|
# Workaround originates from https://stackoverflow.com/a/78724835/12640533
|
|
|
|
class StaticFilesConfig(StaticFilesConfig):
|
|
|
|
"""
|
|
|
|
Application in charge of processing statics files.
|
|
|
|
It replaces the original django staticfiles
|
2024-11-18 14:36:05 +00:00
|
|
|
It integrates scss files and javascript bundling.
|
2024-09-17 21:42:05 +00:00
|
|
|
It makes sure that statics are properly collected and that they are automatically
|
|
|
|
when using the development server.
|
|
|
|
"""
|
|
|
|
|
|
|
|
ignore_patterns = IGNORE_PATTERNS
|
|
|
|
name = "staticfiles"
|