Skip to content

Commit

Permalink
fix(build): force assets to go through vite pipeline during dev too (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Nov 25, 2023
1 parent 479a320 commit c3d7f22
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/node/plugin.ts
Expand Up @@ -95,6 +95,22 @@ export async function createVitePressPlugin(
}
}

const getMergedAssetUrlOptions = () => {
const { transformAssetUrls } = userVuePluginOptions?.template ?? {}
const assetUrlOptions = { includeAbsolute: true }

if (transformAssetUrls && typeof transformAssetUrls === 'object') {
// presence of array fields means this is raw tags config
if (Object.values(transformAssetUrls).some((val) => Array.isArray(val))) {
return { ...assetUrlOptions, tags: transformAssetUrls as any }
} else {
return { ...assetUrlOptions, ...transformAssetUrls }
}
} else {
return assetUrlOptions
}
}

// lazy require plugin-vue to respect NODE_ENV in @vue/compiler-x
const vuePlugin = await import('@vitejs/plugin-vue').then((r) =>
r.default({
Expand All @@ -105,7 +121,8 @@ export async function createVitePressPlugin(
compilerOptions: {
...userVuePluginOptions?.template?.compilerOptions,
isCustomElement
}
},
transformAssetUrls: getMergedAssetUrlOptions()
}
})
)
Expand Down

0 comments on commit c3d7f22

Please sign in to comment.