ionic-team / stencil-ds-output-targets

These are output targets that can be added to Stencil for React and Angular.
https://stenciljs.com
MIT License
247 stars 112 forks source link

setAssetPath is not being exported from the dist-custom-element react binding #186

Open Arvind6353 opened 3 years ago

Arvind6353 commented 3 years ago

Hi,

I have a static asset and to use in the consuming app , I need to use setAssetPath as per the docs .

I see that react binding component is not exporting setAssetPath.

Can you please help fix this.

import { MyComponent} from "fw-design-react";

fw-design-react is the react binding wrapper generated using

reactOutputTarget({
      componentCorePackage: 'fw-design-core',
      proxiesFile: '../react/src/components.ts',
      includeImportCustomElements: true,
      customElementsDir: 'dist/components',
    }),

As per the docs , setAssetPath is imported from the `import { defineCustomElements, setAssetPath } from 'my-library/dist/custom-elements';

setAssetPath(document.currentScript.src); defineCustomElements();`

https://stenciljs.com/docs/custom-elements

@splitinfinities @liamdebeasi

borisdiakur commented 2 years ago

We tried to use setAssetPath in this sandbox app, but to no avail. Currently our workaround here is to configure webpack, so that it copies all assets to the public/assets/ folder, served under /assets/, where the stencil components look for them by default. However, this only works for components used on the base path (/) of the application. If we navigate to a different path, the assets are fetched relatively to that path and we end up 404s. We tried to use import { setAssetPath } from 'our-lib/dist/components' and use the function to change the default behaviour, but it didn't seem to have any effect.