@shixinde/guoguo-vite-plugin-config
Version:
袁果锅生态 - Vite 插件 用于简化配置
30 lines (26 loc) • 794 B
text/typescript
import type { theOptions } from './types/index.d'
/**
* @envPrefix 配置环境变量前缀默认 VITE_
* @envDir 配置环境变量路径,默认为项目根目录
* @title 网站标题
*/
const onReturnPlugin = (opthons?: theOptions): any => {
return {
envPrefix: opthons?.envPrefix || "VITE_",
config(config: any, env: any) {
return {
envDir: opthons?.envDir || '',
}
},
transformIndexHtml(html: any) {
if (opthons?.title) {
return html.replace(
/<title>(.*?)<\/title>/,
`<title>${opthons.title}</title>`
)
}
return null
}
}
}
export default onReturnPlugin;