web icon indicating copy to clipboard operation
web copied to clipboard

Load assets of extension

Open LukasHirt opened this issue 5 years ago • 4 comments

At the moment we load only the js bundle of extension. We need to be able to also load assets in case there are any (e. g. images)

LukasHirt avatar Feb 02 '20 13:02 LukasHirt

Possible solution - use import.meta.url which returns URL where the module is located and access assets with that URL. This is not supported in Edge. Seems that polyfill already exists though https://www.npmjs.com/package/es-module-shims

So the next tasks are:

  • [ ] Test loading assets with this solution
  • [ ] Test polyfill for Edge
  • [ ] Document it so it's available for extensions developers.

LukasHirt avatar Feb 04 '20 20:02 LukasHirt

Using import.meta.url might have become much easier as we're switching to native modules in https://github.com/owncloud/web/pull/7952

dschmidt avatar Dec 07 '22 23:12 dschmidt

Is this issue still relevant given the progress that has been achieved in the overall project and extension system?

pascalwengerter avatar Sep 08 '24 03:09 pascalwengerter

import.meta.url can be used as @LukasHirt pointed out.

c.f. https://github.com/dschmidt/web-app-gpx-viewer/blob/1c0ecfc52fc217bb1a1b4279b7ea445b9d78b1fa/src/composables/useLeaflet.ts#L16

dschmidt avatar Sep 08 '24 15:09 dschmidt

Since it's already in use - closing

LukasHirt avatar Mar 24 '25 10:03 LukasHirt