update
init
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Plugin to minimize and use ejs template syntax in index.html.
|
||||
* https://github.com/anncwb/vite-plugin-html
|
||||
*/
|
||||
import type { PluginOption } from 'vite';
|
||||
import { ViteEjsPlugin } from 'vite-plugin-ejs';
|
||||
import pkg from '../../../package.json';
|
||||
import { GLOB_CONFIG_FILE_NAME } from '../../constant';
|
||||
export function configHtmlPlugin(env: ViteEnv, isBuild: boolean) {
|
||||
const { VITE_GLOB_APP_TITLE, VITE_PUBLIC_PATH, VITE_GLOB_APP_TITLE_JD, VITE_PLATFORM } = env;
|
||||
|
||||
const path = VITE_PUBLIC_PATH.endsWith('/') ? VITE_PUBLIC_PATH : `${VITE_PUBLIC_PATH}/`;
|
||||
|
||||
const getAppConfigSrc = () => {
|
||||
return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${pkg.version}-${new Date().getTime()}`;
|
||||
};
|
||||
|
||||
const htmlPlugin: PluginOption = ViteEjsPlugin({
|
||||
title: VITE_PLATFORM == 'JD' ? VITE_GLOB_APP_TITLE_JD : VITE_GLOB_APP_TITLE,
|
||||
isBuild,
|
||||
isJD: VITE_PLATFORM == 'JD',
|
||||
src: getAppConfigSrc(),
|
||||
});
|
||||
return htmlPlugin;
|
||||
}
|
||||
Reference in New Issue
Block a user