|
|
@ -2,7 +2,7 @@ import path from 'path'
|
|
|
|
import { Plugin } from 'vite'
|
|
|
|
import { Plugin } from 'vite'
|
|
|
|
import { SiteConfig, resolveSiteData } from './config'
|
|
|
|
import { SiteConfig, resolveSiteData } from './config'
|
|
|
|
import { createMarkdownToVueRenderFn } from './markdownToVue'
|
|
|
|
import { createMarkdownToVueRenderFn } from './markdownToVue'
|
|
|
|
import { APP_PATH, SITE_DATA_REQUEST_PATH } from './alias'
|
|
|
|
import { APP_PATH, DEFAULT_THEME_PATH, SITE_DATA_REQUEST_PATH } from './alias'
|
|
|
|
import createVuePlugin from '@vitejs/plugin-vue'
|
|
|
|
import createVuePlugin from '@vitejs/plugin-vue'
|
|
|
|
import slash from 'slash'
|
|
|
|
import slash from 'slash'
|
|
|
|
import { OutputAsset, OutputChunk } from 'rollup'
|
|
|
|
import { OutputAsset, OutputChunk } from 'rollup'
|
|
|
@ -24,7 +24,7 @@ const isPageChunk = (
|
|
|
|
|
|
|
|
|
|
|
|
export function createVitePressPlugin(
|
|
|
|
export function createVitePressPlugin(
|
|
|
|
root: string,
|
|
|
|
root: string,
|
|
|
|
{ configPath, aliases, markdown, site: initialSiteData }: SiteConfig,
|
|
|
|
{ configPath, aliases, markdown, themeDir, site }: SiteConfig,
|
|
|
|
ssr = false,
|
|
|
|
ssr = false,
|
|
|
|
pageToHashMap?: Record<string, string>
|
|
|
|
pageToHashMap?: Record<string, string>
|
|
|
|
): Plugin[] {
|
|
|
|
): Plugin[] {
|
|
|
@ -35,7 +35,9 @@ export function createVitePressPlugin(
|
|
|
|
ssr
|
|
|
|
ssr
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
let siteData = initialSiteData
|
|
|
|
let siteData = site
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isUsingDefaultTheme = themeDir === DEFAULT_THEME_PATH
|
|
|
|
|
|
|
|
|
|
|
|
const vitePressPlugin: Plugin = {
|
|
|
|
const vitePressPlugin: Plugin = {
|
|
|
|
name: 'vitepress',
|
|
|
|
name: 'vitepress',
|
|
|
@ -43,7 +45,14 @@ export function createVitePressPlugin(
|
|
|
|
config() {
|
|
|
|
config() {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
alias: aliases,
|
|
|
|
alias: aliases,
|
|
|
|
transformInclude: /\.md$/
|
|
|
|
transformInclude: /\.md$/,
|
|
|
|
|
|
|
|
define: isUsingDefaultTheme
|
|
|
|
|
|
|
|
? {
|
|
|
|
|
|
|
|
__CARBON__: !!site.themeConfig.carbonAds?.carbon,
|
|
|
|
|
|
|
|
__BSA__: !!site.themeConfig.carbonAds?.custom,
|
|
|
|
|
|
|
|
__ALGOLIA__: !!site.themeConfig.algolia
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
: {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|