Closed ComLock closed 5 years ago
Indeed, I think this sounds like "abuse" of pageContributions"..
Due to https://github.com/enonic/xp/issues/6611 I'm unable to implement a workaround.
Another option would be serving the assets via services, but again the service url contains the app.name in the path, so pageContributions wont be uniqe, and thus duplicated.
I guess I could have a smart response filter that searches pageContribution before adding or not its own. But then the pageContribution is moved from the part into a filter.
Perhaps what I could do is make an Assets Application which provides all the assets, sorta like CDN.
Then all the apps would simply request assets from a static CDN url, rather than providing all the assets it needs.
Perhaps there could some parameter to assetUrl to say give me an url without the hash number. That would make it easier to host assets that already contain versioning in the filename. Like jquery-x.x.x
And perhaps there could be a parameter to drop the app name too, and simply run through the order of the apps in the site looking for the first app to provide the asset?
According to @alansemenov the backend will already provide the asset on this url <appName>/<path to asset>
in addition to <appName>/<assetUrl generated by Enonic>
It would be nice if such a thing was documented anywhere? And even better was available via a parameter to assetUrl, or a new function resourceUrl. Better check though that you cannot download non-assets. Like controllers containing password or other security risks.
If you want a common set of "assets" across apps, you sould make a separate app like you suggest above. Alternatively use CDN deployments outside of your control
When you have two apps that for instane adds react, react-dom and babel-standalone as assets via pagecontribtions in a filter. The will all be duplicated because the asseturl is app specific. It both contains the app name and a number which is also different.
This is another instance where https://github.com/enonic/xp/issues/6122 could be the solution...