Open jcbhmr opened 1 year ago
could be something like this idk
async function resolveConfigExtends(
config: RawConfigExports
): Promise<UserConfig> {
const resolved = await (typeof config === 'function' ? config() : config)
if (resolved.extends) {
const extendsRaw = [resolved.extends].flat();
const manyBases = await Promise.all(
extendsRaw.map((config) => resolveConfigExtends(config))
);
// or reduceRight() depending on which side gets priority
const singleBase = manyBases.reduce((prev, curr) => mergeConfig(prev, curr));
return mergeConfig(singleBase, resolved);
}
return resolved
}
also since mergeConfig()
isn't exported by vitepress, there's no current way to even do this right now without this "extends can be an array" feature:
// this doesnt work
import { mergeConfig } from "vitepress" // mergeConfig() isnt exported by vitepress
export default defineConfig({
extends: mergeConfig(
blog({ rss: true }),
jsdoc({ conf: "jsdoc.json" }),
)
})
Is your feature request related to a problem? Please describe.
problem: extending from two premade "plugin-like" presets: blog & jsdoc
of course, i know i could do it manually, but it'd be nice to support an array like below
Describe the solution you'd like
Describe alternatives you've considered
using a vite plugin like
problem is this doesn't get you access to the pre-normalized config and only lets you mutate the post-normalized config.vitepress.* config stuffs in the vite plugin hooks (if that's even supported by vitepress officially 😬)
Additional context
i think extending a premade config is a pretty good way to go one step higher than just a vite plugin in order to configure vitepress-specific things like sidebars and such. being able to mix multiple of these base configs would be nice imo
if theres another good way to go about the pattern demo'ed above 👆 then id be happy to hear it 😊
Validations