wireguard-dashboard-admin/build/plugin/html.js

33 lines
829 B
JavaScript
Raw Normal View History

2022-05-15 18:51:57 +08:00
import { createHtmlPlugin } from 'vite-plugin-html'
2022-05-03 22:37:51 +08:00
import { version } from '../../package.json'
import { GLOB_CONFIG_FILE_NAME } from '../constant'
2022-01-08 17:20:46 +08:00
export function configHtmlPlugin(viteEnv, isBuild) {
const { VITE_APP_TITLE, VITE_PUBLIC_PATH } = viteEnv
const path = VITE_PUBLIC_PATH.endsWith('/') ? VITE_PUBLIC_PATH : `${VITE_PUBLIC_PATH}/`
const getAppConfigSrc = () => {
return `${path}${GLOB_CONFIG_FILE_NAME}?v=${version}-${new Date().getTime()}`
}
2022-05-15 18:51:57 +08:00
const htmlPlugin = createHtmlPlugin({
2022-01-08 17:20:46 +08:00
minify: isBuild,
inject: {
data: {
title: VITE_APP_TITLE,
},
tags: isBuild
? [
{
tag: 'script',
attrs: {
src: getAppConfigSrc(),
},
},
]
: [],
},
})
return htmlPlugin
}