forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: move collectstatic ignore patterns into configuration
Django provides the `collectstatic` management command, which collects static assets into the STATIC_ROOT so that they can be served by some system external to Django (like nginx or caddy), as is usually desired in production environments. edx-platform contains several types of files that we don't want to be collected into the STATIC_ROOT. Previously, these files had to be supplied to the manageme nt command using the `--ignore` option: ./manage.py lms collectstatic --ignore geoip --ignore sass ...etc ./manage.py cms collectstatic --ignore geoip --ignore sass ...etc This yields a long, hard-to-remember command. Paver wrapped the command in its big `paver update_assets` task, but that task also builds assets, which is totally overkill when you're just trying to collect them. Fortunately, `collectstatic`'s default ignore patterns can be configured by defining a custom AppConfig class. We define such an config (`EdxPlatformStaticFilesConfig`) for LMS and CMS. Now, devs can collect LMS and CMS assets with just: ./manage.py lms collectstatic ./manage.py cms collectstatic Further reading on collecstatic and --ignore: https://docs.djangoproject.com/en/3.2/ref/contrib/staticfiles/#customizing-the-i gnored-pattern-list Further reading on eschewing Paver: https://github.com/openedx/edx-platform/blob/master/docs/decisions/0017-reimplem ent-asset-processing.rst Closes: openedx#31658
- Loading branch information
1 parent
e01afb1
commit d35df76
Showing
4 changed files
with
41 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Configuration utilities for static assets. Shared by LMS and CMS. | ||
""" | ||
from django.contrib.staticfiles.apps import StaticFilesConfig | ||
|
||
|
||
class EdxPlatformStaticFilesConfig(StaticFilesConfig): | ||
""" | ||
A thin wrapper around the standard django.contrib.staticfiles app | ||
which adds the proper file & folder ignore patterns for edx-platform | ||
static asset collection. | ||
This allows devs & operators to run: | ||
./manage.py [lms|cms] collectstatic | ||
instead of: | ||
./manage.py [lms|cms] collectstatic --ignore geoip --ignore sass ... etc. | ||
""" | ||
ignore_patterns = StaticFilesConfig.ignore_patterns + [ | ||
|
||
"geoip", # Geo-IP data, only accessed in Python | ||
"sass", # We compile these out, don't need the source files in staticfiles | ||
"xmodule_js", # Symlink for tests. | ||
|
||
# Karma test related files: | ||
"fixtures", | ||
"karma_*.js", | ||
"spec", | ||
"spec_helpers", | ||
"spec-helpers", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters