You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置Vite或esbuild使其不生成/* @__PURE__ */注解?

如何禁用Vite在JSX代码中生成/* @PURE */注解
  • 这类注解是Vite默认依赖的esbuild在处理JSX时生成的,只需修改Vite配置文件中的esbuild参数即可禁用:
  1. 打开项目根目录下的vite.config.js或vite.config.ts
  2. 在defineConfig配置块中添加esbuild选项,设置pure: false:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],
  esbuild: {
    pure: false // 关闭@PURE注解生成
  }
})
  • 无论你使用React的自动runtime模式还是传统JSX写法,上述配置都能生效。pure选项默认值为true,esbuild会给它判定为无副作用的JSX转换代码添加/* @PURE */注解,将其设为false就能完全阻止这类注解的生成。

内容的提问来源于stack exchange,提问作者citykid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 08:35:23