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

Next.js中如何将@svgr/webpack集成到Turbopack?集成报错求助

Turbopack集成@svgr/webpack报错问题
  • 问题情况:官方文档显示Turbopack兼容@svgr/webpack,但实际集成后出现异常。不使用--turbo(不启用Turbopack)运行项目时一切正常,启用Turbopack后则报错。
  • 报错信息:
Error run turbopack:

Processing image failed
  Failed to parse svg source code for image dimensions
  
  Caused by:
  - Source code does not contain a <svg> root element
  • 当前next.config.js配置:
const nextConfig = {
  webpack(config) {
    config.module.rules.push({
      test: /\.svg$/i,
      use: ["@svgr/webpack"],
    });

    return config;
  },

  experimental: {
    appDir: true,
    turbo: {
      loaders: {
        ".svg": ["@svgr/webpack"],
      },
    },
  },
};

module.exports = nextConfig;

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 22:24:55