Skip to content

Commit

Permalink
fix: Force djangoapps to be loaded before we run webpack.
Browse files Browse the repository at this point in the history
In the specific case of webworkers for proctoring, we need to
force Django to load before we run `npm run webpack` so that
the file ../workers.json gets written. See
https://github.com/openedx/edx-proctoring/blob/73c7f55e2be91324fa07fec6e6ac0a667fdd8412/edx_proctoring/apps.py#L46

Also adds JS_ENV_EXTRA_CONFIG, which is required
to create the webworker config.
  • Loading branch information
dianakhuang committed Dec 17, 2024
1 parent e8e4a68 commit a1a1b23
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions playbooks/roles/edxapp/templates/edx/bin/edxapp-update-assets.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,29 @@
export WEBPACK_CONFIG_PATH=webpack.prod.config.js
export STATIC_ROOT_LMS=/edx/var/edxapp/staticfiles
export STATIC_ROOT_CMS=/edx/var/edxapp/staticfiles/studio
# This is necessary to properly build webworkers, which depends on this value being a dictionary.
export JS_ENV_EXTRA_CONFIG={}


# We need to make a call to a management command before running webpack because proctoring runs a webpack
# webworker that only gets built if the proctoring djangoapp writes out a `workers.json`:
# https://github.com/openedx/edx-proctoring/blob/73c7f55e2be91324fa07fec6e6ac0a667fdd8412/edx_proctoring/apps.py#L4
{% if edxapp_staticfiles_storage_overrides %}
{% for override in edxapp_staticfiles_storage_overrides %}
export STATICFILES_STORAGE={{ override | quote }}
sudo -E -H -u {{ edxapp_user }} \
env "PATH=$PATH" \
npm run webpack \
{{ edxapp_venv_bin }} python manage.py lms --settings=$EDX_PLATFORM_SETTINGS print_setting STATIC_ROOT WEBPACK_CONFIG_PATH \
&& npm run webpack \
&& npm run compile-sass -- --theme-dir /edx/var/edx-themes/edx-themes/edx-platform --theme-dir /edx/app/edxapp/edx-platform/themes \
&& {{ edxapp_venv_bin }}/python manage.py lms collectstatic --noinput --settings=$EDX_PLATFORM_SETTINGS \
&& {{ edxapp_venv_bin }}/python manage.py cms collectstatic --noinput --settings=$EDX_PLATFORM_SETTINGS
{% endfor %}
{% else %}
sudo -E -H -u {{ edxapp_user }} \
env "PATH=$PATH" \
npm run webpack \
{{ edxapp_venv_bin }} python manage.py lms --settings=$EDX_PLATFORM_SETTINGS print_setting STATIC_ROOT WEBPACK_CONFIG_PATH \
&& npm run webpack \
&& npm run compile-sass -- --theme-dir /edx/var/edx-themes/edx-themes/edx-platform --theme-dir /edx/app/edxapp/edx-platform/themes \
&& {{ edxapp_venv_bin }}/python manage.py lms collectstatic --noinput --settings=$EDX_PLATFORM_SETTINGS \
&& {{ edxapp_venv_bin }}/python manage.py cms collectstatic --noinput --settings=$EDX_PLATFORM_SETTINGS
Expand Down

0 comments on commit a1a1b23

Please sign in to comment.