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

Conversation

timmc-edx
Copy link
Member

@timmc-edx timmc-edx commented Nov 4, 2024

After the removal of paver, static assets build wasn't completing properly in edxapp -- static files were written to the correct directory in the assets volume (mounted under /edx/var) but the webpack-stats.json files were written to the test_root dir in the app container (under /edx/app). The service would fail on first page load as it failed to find the stats file, which is apparently used for locating resources.

The static assets build was also taking quite a long time and a lot of CPU, which is likely because we were doing the production-style build with full optimization.

  • Set static-root environment variables so that webpack-stats.json is written to the right place. See staticRootLms and staticRootCms in webpack.common.config.js in edx-platform for where that default is set. Set both LMS/CMS vars for both lms and cms since there's some dependency of CMS on LMS in the logic (and both calls build both sets of files, for better or worse).
  • Use npm dev build for reduced optimization (faster build).
  • Use --settings devstack_docker in the Makefile call to collectstatic; I'm not actually sure what the impact of that is, but it's what was in the provisioning script's version of the call and I needed to deduplicate these calls.
  • Have provision-lms.sh just call the Makefile so that there aren't two sources of truth on how to build static assets for edxapp.

Also:

  • Use same spelling of --no-input for both calls (either works, just make it uniform)

Addresses #65


I've completed each of the following or determined they are not applicable:

  • Made a plan to communicate any major developer interface changes (or N/A)

After the removal of paver, static assets build wasn't completing properly
in edxapp -- static files were written to the correct directory in the
assets volume (mounted under /edx/var) but the webpack-stats.json files
were written to the test_root dir in the app container (under /edx/app).
The service would fail on first page load as it failed to find the stats
file, which is apparently used for locating resources.

The static assets build was also taking quite a long time and a lot of CPU,
which is likely because we were doing the production-style build with full
optimization.

- Set static-root environment variables so that webpack-stats.json is
  written to the right place. See `staticRootLms` and `staticRootCms` in
  `webpack.common.config.js` in edx-platform for where that default is set.
  Set both LMS/CMS vars for both lms and cms since there's some dependency
  of CMS on LMS in the logic (and both calls build both sets of files, for
  better or worse).
- Use npm dev build for reduced optimization (faster build).
- Use `--settings devstack_docker` in the Makefile call to collectstatic;
  I'm not actually sure what the impact of that is, but it's what was in
  the provisioning script's version of the call and I needed to deduplicate
  these calls.
- Have `provision-lms.sh` just call the Makefile so that there aren't two
  sources of truth on how to build static assets for edxapp.

Also:

- Use same spelling of `--no-input` for both calls (either works, just
  make it uniform)

Addresses #65
@timmc-edx timmc-edx force-pushed the timmc/webpack-post-paver branch from 5d2005c to 64585d4 Compare November 4, 2024 20:18
Copy link
Member

@UsamaSadiq UsamaSadiq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested the provision locally against this branch. All the static assets were built successfully and local endpoint also loaded up fine.

@UsamaSadiq
Copy link
Member

The failing macos check will be fixed once the PR #58 is merged.

@timmc-edx timmc-edx merged commit 7098198 into master Nov 6, 2024
10 of 11 checks passed
@timmc-edx timmc-edx deleted the timmc/webpack-post-paver branch November 6, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants