Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Write webpack stats file to right place (so static assets can load) #66

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -443,11 +443,14 @@ $(foreach asset_service,$(ASSET_SERVICES_LIST),\

dev.static: | $(_asset_compilation_targets)

# Put webpack-stats.json in the right place during NPM build:
EDXAPP_STATIC_ROOT_ENV=STATIC_ROOT_LMS=/edx/var/edxapp/staticfiles STATIC_ROOT_CMS=/edx/var/edxapp/staticfiles/studio

dev.static.lms:
docker compose exec -T lms bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && npm run build && ./manage.py lms collectstatic --noinput'
docker compose exec -T lms bash -c "source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && $(EDXAPP_STATIC_ROOT_ENV) npm run build-dev && ./manage.py lms collectstatic --no-input --settings devstack_docker"

dev.static.cms:
docker compose exec -T cms bash -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && npm run build && ./manage.py cms collectstatic --no-input'
docker compose exec -T cms bash -c "source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform/ && $(EDXAPP_STATIC_ROOT_ENV) npm run build-dev && ./manage.py cms collectstatic --no-input --settings devstack_docker"

dev.static.%: ## Rebuild static assets for the specified service's container.
docker compose exec -T $* bash -c 'source /edx/app/$*/$*_env && cd /edx/app/$*/$*/ && make static'
Expand Down
13 changes: 13 additions & 0 deletions docs/troubleshoot_general_tips.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,19 @@ Past problems (fixed)

If you see any of the following issues, you'll need to `update your repos and pull the latest images <updating devstack_>`_.

webpack-stats.json not found
----------------------------

In a devstack provisioned after May 2024, loading any page in LMS would fail with::

OSError at /

Error reading /edx/var/edxapp/staticfiles/webpack-stats.json. Are you sure webpack has generated the file and the path is correct?

CMS would give the same error, but with path ``/edx/var/edxapp/staticfiles/studio/webpack-stats.json``. Static asset generation also took overly long and consumed more CPU than necessary.

This was resolved in `<https://github.com/edx/devstack/pull/66>`__ in November 2024 with an adjustment to the Makefile. Updating to a more recent devstack and re-running ``make lms-static cms-static`` should fix this, but as a quick workaround, the webpack-stats.json files can be manually moved from ``/edx/app/edxapp/edx-platform/test_root/staticfiles/{studio/,}webpack-stats.json`` to ``/edx/var/edxapp/staticfiles/{studio/,}webpack-stats.json``.

Permission denied for copying studio-frontend JS & CSS during provisioning
--------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion provision-lms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ done

# Create static assets for both LMS and CMS
for app in "${apps[@]}"; do
docker compose exec -T $app bash -e -c 'source /edx/app/edxapp/edxapp_env && cd /edx/app/edxapp/edx-platform && npm run build && ./manage.py lms collectstatic --noinput --settings devstack_docker && ./manage.py cms collectstatic --noinput --settings devstack_docker'
make "dev.static.$app"
done

# Allow LMS SSO for CMS
Expand Down
Loading