Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose @vitejs/plugin-vue config #215

Merged
merged 3 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { resolveAliases, APP_PATH, DEFAULT_THEME_PATH } from './alias'
import { SiteData, HeadConfig, LocaleConfig } from '../../types/shared'
import { MarkdownOptions } from './markdown/markdown'
import { AliasOptions } from 'vite'
import { Options } from '@vitejs/plugin-vue'
ChrisShank marked this conversation as resolved.
Show resolved Hide resolved
export { resolveSiteDataByRoute } from './shared/config'

const debug = require('debug')('vitepress:config')
Expand All @@ -21,6 +22,7 @@ export interface UserConfig<ThemeConfig = any> {
alias?: Record<string, string>
markdown?: MarkdownOptions
customData?: any
vueOptions: Options
ChrisShank marked this conversation as resolved.
Show resolved Hide resolved
}

export interface SiteConfig<ThemeConfig = any> {
Expand All @@ -33,6 +35,7 @@ export interface SiteConfig<ThemeConfig = any> {
alias: AliasOptions
pages: string[]
markdown?: MarkdownOptions
vueOptions: Options
}

const resolve = (root: string, file: string) =>
Expand All @@ -59,7 +62,8 @@ export async function resolveConfig(
outDir: resolve(root, 'dist'),
tempDir: path.resolve(APP_PATH, 'temp'),
markdown: userConfig.markdown,
alias: resolveAliases(themeDir, userConfig)
alias: resolveAliases(themeDir, userConfig),
vueOptions: userConfig.vueOptions
}

return config
Expand Down
5 changes: 3 additions & 2 deletions src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ const isPageChunk = (

export function createVitePressPlugin(
root: string,
{ configPath, alias, markdown, site }: SiteConfig,
{ configPath, alias, markdown, site, vueOptions }: SiteConfig,
ssr = false,
pageToHashMap?: Record<string, string>
): Plugin[] {
const markdownToVue = createMarkdownToVueRenderFn(root, markdown)

const vuePlugin = createVuePlugin({
include: [/\.vue$/, /\.md$/]
include: [/\.vue$/, /\.md$/],
...vueOptions
antfu marked this conversation as resolved.
Show resolved Hide resolved
})

let siteData = site
Expand Down