#Sentry in Standalone Build

31 messages · Page 1 of 1 (latest)

hollow bear
#

I am trying to use sentry with next.js and a standalone build. Once I ran the sentry wizard and it updated the next.config.js but broke the standalone build.

I had to change the next.config.js to next.config.cjs and this is the config:

/**
 * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
 * for Docker builds.
 */
await import("./src/env.js");

/** @type {import("next").NextConfig} */
const config = {
    output: "standalone"    
};

export default config;


// Injected content via Sentry wizard below

const { withSentryConfig } = require("@sentry/nextjs");

module.exports = withSentryConfig(
  module.exports,
  {
    // For all available options, see:
    // https://github.com/getsentry/sentry-webpack-plugin#options

    // Suppresses source map uploading logs during build
    silent: true,
    org: "my-org",
    project: "my-project",
  },
  {
    // For all available options, see:
    // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

    // Upload a larger set of source maps for prettier stack traces (increases build time)
    widenClientFileUpload: true,

    // Transpiles SDK to be compatible with IE11 (increases bundle size)
    transpileClientSDK: true,

    // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
    tunnelRoute: "/monitoring",

    // Hides source maps from generated client bundles
    hideSourceMaps: true,

    // Automatically tree-shake Sentry logger statements to reduce bundle size
    disableLogger: true,

    // Enables automatic instrumentation of Vercel Cron Monitors.
    // See the following for more information:
    // https://docs.sentry.io/product/crons/
    // https://vercel.com/docs/cron-jobs
    automaticVercelMonitors: true,
  }
);

It seems to be ignoring the standalone because when I build it, it no longer creates the standalone folder.

bitter gazelleBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

brittle ether
# hollow bear I am trying to use sentry with next.js and a standalone build. Once I ran the se...

should be passing config to first arg of withSentryConfig instead of module.exports

module.exports = withSentryConfig(
  config,
  {
    // For all available options, see:
    // https://github.com/getsentry/sentry-webpack-plugin#options

    // Suppresses source map uploading logs during build
    silent: true,
    org: "my-org",
    project: "my-project",
  },
  {
    // For all available options, see:
    // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

    // Upload a larger set of source maps for prettier stack traces (increases build time)
    widenClientFileUpload: true,

    // Transpiles SDK to be compatible with IE11 (increases bundle size)
    transpileClientSDK: true,

    // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
    tunnelRoute: "/monitoring",

    // Hides source maps from generated client bundles
    hideSourceMaps: true,

    // Automatically tree-shake Sentry logger statements to reduce bundle size
    disableLogger: true,

    // Enables automatic instrumentation of Vercel Cron Monitors.
    // See the following for more information:
    // https://docs.sentry.io/product/crons/
    // https://vercel.com/docs/cron-jobs
    automaticVercelMonitors: true,
  }
);
#

and remove the export default config; too

hollow bear
#

ok thanks, let me give it a try

#

hmm I did that and it isn't creating the standalone either

#

Is it something due to me renaming the file to .cjs?

brittle ether
#

what version of nextjs are you using?

hollow bear
#

14.0.4

#

I adjusted the config to this


await import("./src/env.js");

/** @type {import("next").NextConfig} */
const config = {
    output: "standalone"    
};

// Injected content via Sentry wizard below
const { withSentryConfig } = require("@sentry/nextjs");

module.exports = withSentryConfig(
  config,
  // Sentry Config here
);

And still got the same result

brittle ether
#

cjs not work for me too but mjs does

hollow bear
#

let me try that

#
Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error
brittle ether
#
/**
 * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
 * for Docker builds.
 */
// await import("./src/env.js");
const { withSentryConfig } = await import("@sentry/nextjs");

/** @type {import("next").NextConfig} */
const nextConfig = {
  output: "standalone",
};

// Injected content via Sentry wizard below

export default withSentryConfig(nextConfig, {
  // For all available options, see:
  // https://github.com/getsentry/sentry-webpack-plugin#options

  // Suppresses source map uploading logs during build
  silent: true,
  org: "my-org",
  project: "my-project",
});

#

use export default

hollow bear
#

running the build now, when does it move to the standalone folder?

#

the build takes a few mins, so wondering if it moves it last

brittle ether
#

let me see

#

when the build finished

hollow bear
#

ok I will keep you posted, it is still building

#

thanks for the help regardless, this is the kind of stuff that drives me nuts in node

brittle ether
#

np, does it work for you?

hollow bear
#

still building

#

it is a huge project

brittle ether
#

big site lol

#

oh

hollow bear
#

yeah takes about 5-7 mins on a M1 Max mbp

#

that worked

#

thanks so much

brittle ether
hollow bear
#

will do