Skip to content

Commit

Permalink
feat: add vue options config (expose @vitejs/plugin-vue) (#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisShank authored Feb 9, 2021
1 parent b82d8f2 commit 5b34c6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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 as VuePluginOptions } from '@vitejs/plugin-vue'
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?: VuePluginOptions
}

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

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
})

let siteData = site
Expand Down

0 comments on commit 5b34c6a

Please sign in to comment.