geert-janklaps / cds-launchpad-plugin

Launchpad Plugin for demo / development / testing SAP CAP-based projects
MIT License
12 stars 13 forks source link

"Reuse" library support? #24

Open nils opened 6 months ago

nils commented 6 months ago

Hi @geert-janklaps,

I have a "reuse library" in my project, and I'm using cds-launchpad-plugin in combination with cds-ui5-plugin.

Now when I want to to use a resource MyResource from my.namespace.library from one of my applications (my.namespace.app1), it won't be able to load that resource (because it's trying to load from https://ui5.sap.com/resources/my/namespace/library/MyResource.js which is the last resort).

I think two things would need to be changed to enable that use case:

  1. cds-ui5-plugin should serve also libraries (as far as I understood, it does not do that at the moment).
  2. cds-launchpad-plugin needs to add resourceroots to the UI5 bootstrap element in the sandbox launchpad.

But before I open an issue over at cds-ui5-plugin and try to create corresponding pull requests on both components, I first wanted to check with you (and other potential readers) if there's another solution I might have missed.

nils commented 5 months ago

For the second bullet point mentioned above, one option is to

  1. copy the template files from ./node_modules/cds-launchpad-plugin/templates/legacy/{launchpad.html,appconfig.json} to ./tools/launchpad/,
  2. add the resourceroots as necessary in the launchpad.html copy and
  3. use that copied template (use relative paths to node_modules/cds-launchpad-plugin/templates, e.g. from package.json):
...
"cds": {
    ...
    "launchpad": {
      "template": "../../../tools/launchpad"
    }
}
...