DioxusLabs / DioxusLabs/dioxus
Adjust asset references in CSS/JS/JSON in Manganis
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
## Feature Request
When Manganis processes an asset like `logo.png` it will change the name by adding a hash of the file contents to help with caching. If, however, a CSS file refers to this asset with its original name, it will not work correctly after the build process. For example
```css
background-image: url('/assets/logo.png');
```
Same issue happens also with JS or JSON files referring to assets. Common case would be providing a manifest JSON for multiple icon files
```json
{
"icons": [
{ "src": "/assets/icon.png", "type": "image/png", "sizes": "48x48" },
{ "src": "/assets/icon-large.png", "type": "image/png", "sizes": "128x128" }
]
}
```
CSS files may also import other CSS files. Although this might be already be handled by the minification process by combining them all in one file?
```css
/* more styles */
@import url("my-imported-styles.css");
```
In all these cases, Manganis should fix these filenames to the new generated name and update the respective textual asset files.
This is something that JS tools like Webpack already do, at least to some extent.
## Implement Suggestion
Add an asset option for fixing the affected names when encountered in a text file. When processing assets, identify files containing references to other assets, build a dependency graph, process the assets in correct order generating new names, update new asset names into files.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.