Skip to content

Conversation

@ralphbean
Copy link

Fix hardcoded image paths for subpath deployments

The current code has hardcoded absolute image paths in src/graphing/components/quadrants.js that prevent the radar from working when deployed to a URL subpath. Paths like /images/new.svg resolve to the domain root instead of the deployment path, breaking image loading for GitLab Pages, GitHub Pages, and similar subpath deployments.

This change imports the images using require() so webpack can process them with the correct publicPath. The images are imported at the module level and referenced by variable instead of hardcoded string paths. This allows webpack to automatically resolve paths correctly for any deployment location, whether at root or a subpath.

The fix follows the existing pattern used in common.js where other images are already imported with require(). No configuration changes are needed and there are no breaking changes for existing deployments.

Changes affect renderRadarLegends() where four icon paths are replaced with imported variables, and renderMobileView() where dynamic path construction is replaced with a mapping object for the quadrant background images.

Replaces hardcoded absolute image paths (/images/*.svg) in quadrants.js
with webpack require() imports. This allows the radar to work correctly
when deployed to URL subpaths (e.g., /team/radar/) instead of only at
the root path.

The hardcoded paths resolve to the domain root regardless of deployment
location, breaking image loading for subpath deployments. By importing
images with require(), webpack processes them with the correct publicPath
automatically.

Changes:
- Import image assets at module level
- Replace hardcoded strings in renderRadarLegends()
- Use mapping object for dynamic quadrant backgrounds in renderMobileView()

Tested by building with npm run build:prod and verifying webpack processes
the paths correctly.

Signed-off-by: Ralph Bean <[email protected]>
@ralphbean ralphbean requested a review from a team as a code owner December 11, 2025 15:01
Adds moduleNameMapper to jest.config.js to mock image file imports with
a simple string stub. This fixes test failures introduced by webpack
require() imports for SVG files, which Jest cannot parse as JavaScript.

Without this configuration, Jest attempts to parse SVG files as JS code,
resulting in "SyntaxError: Unexpected token '<'" when importing images.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Signed-off-by: Ralph Bean <[email protected]>
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.

1 participant