UNPKG

@nolebase/integrations

Version:

A unconfig (unified configurations) for both VitePress and VitePress theme. Supporting all Nólëbase Integrations with default theme.

90 lines (84 loc) 2.84 kB
'use strict'; const node_path = require('node:path'); const defu = require('defu'); const vite = require('@nolebase/vitepress-plugin-git-changelog/vite'); const vite$1 = require('@nolebase/vitepress-plugin-page-properties/vite'); const vite$2 = require('@nolebase/vitepress-plugin-thumbnail-hash/vite'); function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; } const defu__default = /*#__PURE__*/_interopDefaultCompat(defu); function presetVite(options) { const opts = defu__default(options, { gitChangelog: { options: { gitChangelog: { maxGitLogCount: 2e3 }, markdownSection: { excludes: [ node_path.join("pages", "en", "index.md"), node_path.join("pages", "zh-CN", "index.md"), node_path.join("README.md"), node_path.join("index.md") ] } } }, pageProperties: { options: { markdownSection: { excludes: [ node_path.join("pages", "en", "index.md"), node_path.join("pages", "zh-CN", "index.md"), node_path.join("README.md"), node_path.join("index.md") ] } } }, thumbnailHashImages: true }); const plugins = []; if (opts.gitChangelog) { plugins.push(vite.GitChangelog(opts.gitChangelog.options.gitChangelog)); plugins.push(vite.GitChangelogMarkdownSection(opts.gitChangelog.options.markdownSection)); } if (opts.pageProperties) { plugins.push(vite$1.PageProperties()); plugins.push(vite$1.PagePropertiesMarkdownSection(opts.pageProperties.options?.markdownSection)); } if (opts.thumbnailHashImages) { plugins.push(vite$2.ThumbnailHashImages()); } return { name: "nolebase:vitepress", plugins: () => plugins || [], config: () => { return { optimizeDeps: { // vitepress is aliased with replacement `join(DIST_CLIENT_PATH, '/index')` // This needs to be excluded from optimization exclude: [ "vitepress", "@nolebase/ui", "@nolebase/ui-asciinema", "@nolebase/ui-rive-canvas", "@nolebase/vitepress-plugin-enhanced-mark", "@nolebase/vitepress-plugin-enhanced-readabilities", "@nolebase/vitepress-plugin-git-changelog", "@nolebase/vitepress-plugin-highlight-targeted-heading", "@nolebase/vitepress-plugin-index", "@nolebase/vitepress-plugin-inline-link-preview", "@nolebase/vitepress-plugin-page-properties", "@nolebase/vitepress-plugin-thumbnail-hash" ] }, ssr: { noExternal: [ "@nolebase/**" ] } }; } }; } exports.presetVite = presetVite;