From 20c997602556340a70639f65464120204d4e4fd8 Mon Sep 17 00:00:00 2001 From: Burt <1020103647@qq.com> Date: Thu, 4 Jan 2024 10:43:38 +0800 Subject: [PATCH] =?UTF-8?q?build(vite):=20=E4=BC=98=E5=8C=96=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=8E=AF=E5=A2=83=E4=B8=8B=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 00305e3..7887315 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -17,6 +17,7 @@ import autoprefixer from 'autoprefixer' /** 这个修改只对web生效,小程序没有index.html这个文件 */ const htmlPlugin = (title: string) => { + console.log('---htmlPlugin---') return { name: 'html-transform', transformIndexHtml(html) { @@ -40,13 +41,14 @@ export default ({ command, mode }) => { // loadEnv(): 返回当前环境env文件中额外定义的变量 const env = loadEnv(mode, path.resolve(process.cwd(), 'env')) console.log(env) + console.log(process.env.UNI_PLATFORM) // 得到 mp-weixin, h5 等 return defineConfig({ plugins: [ // UniPages() 需要在 Uni() 之前引入 UniPages(), Uni(), UnoCSS(), - htmlPlugin(env.VITE_APP_TITLE), + process.env.UNI_PLATFORM === 'h5' && htmlPlugin(env.VITE_APP_TITLE), svgLoader(), // 打包分析插件 mode === 'production' &&