It's important that when you are developing an Application Extension that you are able to both add assets to your extension code as well as access those extensions. In this PR we modify the Web Pack configuration to ensure that all assets places in an Application Extensions /static folder are bundled with all the other assets.
Additionally we want to create a utility to allow developers to access these static assets. Here we created a new utility called getStaticAssetUrl that will return a url to a static asset provided it's relative path. Optionally you can pass in any extensions package name that will be used to access that static asset in the extensions folder.
NOTE: This isn't an ideal API and having to pass in the the package name will get tedious. However this is the groundwork to hopefully come up with a react-y hooks api where we can simple do something like useStaticAssetUrl() and it will just know what extension you are in. But unfortunately I wasn't able to get something like that in the time given for this ticket.
Types of Changes
[ ] Bug fix (non-breaking change that fixes an issue)
[x] New feature (non-breaking change that adds functionality)
[ ] Documentation update
[ ] Breaking change (could cause existing functionality to not work as expected)
[ ] Other changes (non-breaking changes that does not fit any of the above)
Changes
Update webpack config to include application extensions static folder.
Description
It's important that when you are developing an Application Extension that you are able to both add assets to your extension code as well as access those extensions. In this PR we modify the Web Pack configuration to ensure that all assets places in an Application Extensions
/static
folder are bundled with all the other assets.Additionally we want to create a utility to allow developers to access these static assets. Here we created a new utility called
getStaticAssetUrl
that will return a url to a static asset provided it's relative path. Optionally you can pass in any extensions package name that will be used to access that static asset in the extensions folder.NOTE: This isn't an ideal API and having to pass in the the package name will get tedious. However this is the groundwork to hopefully come up with a react-y hooks api where we can simple do something like
useStaticAssetUrl()
and it will just know what extension you are in. But unfortunately I wasn't able to get something like that in the time given for this ticket.Types of Changes
Changes
How to Test-Drive This PR
extension-sample
project and accessed using thegetStaticAsset
utility.Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization