Skip to content

Add node_modules to STATICFILES_DIRS when STATICFILES_USE_NPM is enabled - #1291

Open
James-Dolinar wants to merge 2 commits into
mainfrom
tethys-offline
Open

Add node_modules to STATICFILES_DIRS when STATICFILES_USE_NPM is enabled#1291
James-Dolinar wants to merge 2 commits into
mainfrom
tethys-offline

Conversation

@James-Dolinar

Copy link
Copy Markdown
Contributor

Description

Fixes the issue where putting STATICFILES_USE_NPM: true under settings in portal_config.yml causes the tethys portal to be unable to find the css and js static files.

tethys_portal/settings.py was checking for STATICFILES_USE_NPM under TETHYS_PORTAL_CONFIG only when adding the static files paths resulting in the path not being added when STATICFILES_USE_NPM is located at the top level. The setting still applied in this scenario resulting in the portal not being able to find the static files.

Putting STATICFILES_USE_NPM either under the top level or TETHYS_PORTAL_CONFIG both properly add the static files path.

Changes Made to Code

  • Add a check for STATICFILES_USE_NPM under the top level when adding the static files path

Related PRs, Issues, and Discussions

Additional Notes

Quality Checks

  • At least one new test has been written for new code
  • New code has 100% test coverage
  • Code has been formatted with Black
  • Code has been linted with flake8
  • Docstrings for new methods have been added
  • The documentation has been updated appropriately

- settings.py only appended node_modules to STATICFILES_DIRS when
  STATICFILES_USE_NPM was set under TETHYS_PORTAL_CONFIG
- The generic settings loader later applies any remaining top-level keys
  to the Django settings module, so STATICFILES_USE_NPM declared at the
  top level of the `settings` block would enable NPM mode, switching
  templates from CDN to /static/ URLs without ever adding
  node_modules to the static paths
- The portal then requested local JavaScript and CSS dependencies that
  were never served, returning 404s and leaving the portal unstyled
- Also check for STATICFILES_USE_NPM at the top level so the
  node_modules path is added whenever NPM mode is on, regardless of
  where it's declared
@coveralls

coveralls commented Jul 27, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 99.993%. remained the same — tethys-offline into main

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