首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Next.js Sentry源地图大小太大

Next.js Sentry源地图大小太大
EN

Stack Overflow用户
提问于 2020-05-30 01:16:48
回答 1查看 596关注 0票数 2

我正在尝试使用next.js的源地图功能,以便更好地调试sentry,但当我构建下一个应用程序时,它试图将大的源地图文件上传到sentry.Is,有什么问题吗?

另外,我的next.config.js配置是这样的。

代码语言:javascript
复制
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
const withSourceMaps = require('@zeit/next-source-maps')();

webpack: (config, { dev, isServer, buildId }) => {
    if (!isServer) {
      config.resolve.alias['@sentry/node'] = '@sentry/browser';
    }
    if (process.env.NODE_ENV === 'production') {
      config.plugins.push(
        new SentryWebpackPlugin({
          include: './app/.next',
          ignore: ['node_modules'],
          urlPrefix: '~/_next',
          release: buildId,
        }),
      );
    }

    return config;}
EN

回答 1

Stack Overflow用户

发布于 2021-05-04 23:31:04

  • npm remove @zeit/next-source-maps

  • npm i next@latest

nextjs现在有内置的配置来在生产https://nextjs.org/docs/advanced-features/source-maps中启用源映射,我还建议忽略*.css.map和其他不需要的文件,所以不要上传它们。

代码语言:javascript
复制
const SentryWebpackPlugin = require('@sentry/webpack-plugin');

...
module.exports = {
...
productionBrowserSourceMaps: process.env.NODE_ENV === 'production',
...
webpack: (config, { dev, isServer, buildId }) => {
    if (!isServer) {
      config.resolve.alias['@sentry/node'] = '@sentry/browser';
    }
    if (process.env.NODE_ENV === 'production') {
      config.plugins.push(
        new SentryWebpackPlugin({
          include: './app/.next',
          ignore: ['node_modules', '*.css.map'],
          stripPrefix: ['webpack://_N_E/'],
          urlPrefix: '~/_next',
          release: buildId,
        }),
      );
    }

    return config;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62091330

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档