ice icon indicating copy to clipboard operation
ice copied to clipboard

使用 vite-plugin-index-html 后,index.html 中的环境变量生产环境不会被替换,能否使用vite-plugin-html 进行替换?

Open linxianxi opened this issue 8 months ago • 3 comments

Describe the bug

能否使用vite-plugin-html 进行替换?可以的话要怎么进行配置?

Expected behavior

index.html 中的环境变量能被正确替换

Actual behavior

No response

Version of ice.js

latest

Content of build.json or ice.config.mts


Additional context

No response

linxianxi avatar Apr 29 '25 02:04 linxianxi

ice.js 2.x 内置 vite 版本相对比较老了,可以参考社区插件进行实现

ClarkXia avatar Apr 29 '25 02:04 ClarkXia

ice.js 2.x 内置 vite 版本相对比较老了,可以参考社区插件进行实现

改为 vite-plugin-html 不行,帮忙看下?

import { createHtmlPlugin } from 'vite-plugin-html';

createHtmlPlugin({
    template: resolve(__dirname, 'index.html'),
    entry: resolve(__dirname, 'src/main.tsx'),
  }),


 build: {
      rollupOptions: {
        preserveEntrySignatures: 'exports-only',
      },
    },

linxianxi avatar Jun 12 '25 09:06 linxianxi

vite-plugin-index-html 代码参考 https://github.com/alibaba/ice/tree/stable/2.x/packages/vite-plugin-index-html

ClarkXia avatar Jun 23 '25 03:06 ClarkXia