Thanks for sharing the issue — to resolve this issue you can try to follow these steps:
Use Relative Paths with SCSS Interpolation
Wrap your asset path in #{ }
to prevent Angular's build system from processing the URL at compile time. This ensures the path remains unchanged in the final CSS:
content: url(#{'vx-grid-assets/icons/indeterminate-box.svg'});
This syntax bypasses Angular's path resolution during build while preserving the correct relative path for runtime.
Verify Asset Configuration
Ensure your angular.json
correctly maps assets to the output directory:
{
"glob": "**/*",
"input": "./common-libraries/vx-grid/vx-grid-resources/assets",
"output": "vx-grid-assets"
}
This copies assets to dist/vx-grid-assets/
during build.
Deployment to Salesforce
Since Salesforce serves static resources from a unique base path (e.g., /resource//
), relative paths like vx-grid-assets/...
will resolve correctly at runtime. Avoid absolute paths (e.g., /vx-grid-assets/...
), as they break in Salesforce's environment.
#{ }
defers path resolution to runtime[5].vx-grid-assets/...
) align with Salesforce’s serving model, where resources are relative to the app’s root in the static archive.// Component SCSS
.my-icon {
&::before {
content: url(#{'vx-grid-assets/icons/indeterminate-box.svg'});
width: 16px;
height: 16px;
}
}
input
/output
paths in angular.json
.[salesforce-domain]/resource/.../vx-grid-assets/icons/...
.dist/vx-grid-assets/
after building.This approach balances Angular’s build requirements with Salesforce’s static resource constraints, ensuring icons load in both environments.