Skip to content

Commit

Permalink
fix: fallback to default asset path instead of throwing
Browse files Browse the repository at this point in the history
  • Loading branch information
borisdiakur committed Nov 9, 2022
1 parent 2129379 commit 72c357c
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/liquid/utils/assetPath.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
import { Build } from '@stencil/core'

/**
* Reads components asset path config from meta tag or global variable.
* This is a workaround until the following issues are resolved:
* https://github.com/ionic-team/stencil/issues/3470
* https://github.com/ionic-team/stencil-ds-output-targets/issues/186
*/
export const getAssetPath = (path: string) => {
const assetBasePath = Build.isTesting
? '/'
: document.head.querySelector<HTMLMetaElement>('meta[data-ld-asset-path]')
?.dataset.ldAssetPath || window.__LD_ASSET_PATH__
if (!assetBasePath) {
throw new Error(
'Asset path not set yet. See https://liquid.emd.design/liquid/guides/component-assets/'
)
}
const assetBasePath =
document.head.querySelector<HTMLMetaElement>('meta[data-ld-asset-path]')
?.dataset.ldAssetPath ||
window.__LD_ASSET_PATH__ ||
'/'
let assetPath = path

if (path.startsWith('./')) {
Expand Down

1 comment on commit 72c357c

@vercel
Copy link

@vercel vercel bot commented on 72c357c Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

liquid – ./

liquid-uxsd.vercel.app
liquid-git-main-uxsd.vercel.app
liquid-oxygen.vercel.app

Please sign in to comment.