提交 650c3164 编写于 作者: fxy060608's avatar fxy060608

feat: add transformIndexHtml

上级 e595b6a5
......@@ -11,6 +11,7 @@ import { createConfigResolved } from './configResolved'
import { createConfigureServer } from './configureServer'
import { createHandleHotUpdate } from './handleHotUpdate'
import { initExtraPlugins } from './utils'
import { createTransformIndexHtml } from './transformIndexHtml'
const debugUni = debug('vite:uni:plugin')
......@@ -79,6 +80,7 @@ export default function uniPlugin(
configResolved: createConfigResolved(options),
configureServer: createConfigureServer(options),
handleHotUpdate: createHandleHotUpdate(options),
transformIndexHtml: createTransformIndexHtml(options),
})
plugins.push(...uniPlugins)
return plugins
......
import { Plugin } from 'vite'
import { VitePluginUniResolvedOptions } from '..'
import { parseManifestJsonOnce } from '../../../uni-cli-shared/dist'
export function createTransformIndexHtml({
inputDir,
}: VitePluginUniResolvedOptions): Plugin['transformIndexHtml'] {
return async function (html) {
const manifestJson = parseManifestJsonOnce(inputDir)
const title = manifestJson.h5?.title || manifestJson.name || ''
return html.replace(/<title>(.*?)<\/title>/, `<title>${title}</title>`)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册