Allow specifying type for `web.resource` scripts in config
Specific Demand
At the moment the scripts section of the config allows specifying only the src values of script to inject.
It would be great to also be able to (optionally) specify the type (and other attributes?). My particular use-case is "module" type scripts.
Implement Suggestion
Guess we would need to allow more complex entries in the scripts parts of the config rather than just PathBufs: https://github.com/DioxusLabs/dioxus/blob/a3e6d0adcaee49495db5c324dbf9f20d5ec529ed/packages/cli/src/config.rs#L178-L182
to be injected here : https://github.com/DioxusLabs/dioxus/blob/a3e6d0adcaee49495db5c324dbf9f20d5ec529ed/packages/cli/src/builder.rs#L477-L483
This would be a great addition! We need a way to set the type of script to include. We could make a new struct that handles the script with path and options. As long as that struct implements serialize and deserialize, it will work with the toml format.
In the longer term, it could make sense to include assets in rust code instead of in the Dioxus.toml (https://github.com/DioxusLabs/dioxus/issues/1283)
Edit: This works only when using Dioxus Web, not in WebView (i.e. Desktop)
For a workaround following code seems to work, if you include it in your rsx! macro:
script {
"type": "module",
src: "https://cdn.example.com/your-module.js"
},
We dropped the resource dir in favor of magnanis in 0.6, so this is no long relevant. You can use head::Link head::Title, head:: etc to specify the type of asset in your code.
Linked: #2635 #2642