Update plugin JS URL handling

This commit is contained in:
Andrew Kingston 2022-10-04 16:28:21 +01:00
parent 4e6f3d44b7
commit ae38d75be0
2 changed files with 21 additions and 3 deletions

View File

@ -88,9 +88,7 @@
<!-- But before loadBudibase is called -->
{#if usedPlugins?.length}
{#each usedPlugins as plugin}
<script
type="application/javascript"
src={`/plugins/${plugin.jsUrl}`}></script>
<script type="application/javascript" src={plugin.jsUrl}></script>
{/each}
{/if}
<script type="application/javascript">

View File

@ -0,0 +1,20 @@
import env from "../environment"
import { plugins as ProPlugins } from "@budibase/pro"
export const enrichPluginURLs = plugins => {
if (!plugins || !plugins.length) {
return []
}
return plugins.map(plugin => {
const cloud = !env.SELF_HOSTED
// In self host we need to prefix the path, as "plugins" is not part of the
// bucket path. In cloud, "plugins" is already part of the bucket path.
let jsUrl = cloud ? "https://cdn.budi.live/" : "/plugins/"
jsUrl += ProPlugins.getBucketPath(plugin.name)
jsUrl += "plugin.min.js"
return {
...plugin,
jsUrl,
}
})
}