UNPKG

@sentry-internal/lynx-plugin

Version:
57 lines (54 loc) 1.78 kB
import { sentryWebpackPlugin } from '@sentry/webpack-plugin/webpack5'; import { createSentrySymbolicatorMiddleware } from './middleware.mjs'; import { logger } from '@sentry/core'; import { PREFIX } from './prefix.mjs'; /** * Create a rsbuild plugin for Sentry Lynx SDK. * * @example * ```ts * // lynx.config.ts * import { pluginSentryLynx } from '@sentry/lynx-react/plugin' * export default { * plugins: [pluginSentryLynx({ * org: 'your-organization', * project: 'your-project', * authToken: process.env.SENTRY_AUTH_TOKEN, * })], * } * ``` * * @public */ function pluginSentryLynx(options) { const { debug, localSymbolication = true } = options; if (debug) { logger.enable(); } return { name: 'sentry:rsbuild:lynx', setup(api) { api.modifyRspackConfig((config) => { var _a; (_a = config.plugins) === null || _a === void 0 ? void 0 : _a.push(sentryWebpackPlugin(options)); }); if (localSymbolication) { api.modifyRsbuildConfig((config) => { var _a; if (!config.dev) { logger.warn(`${PREFIX} No dev configuration found for Sentry Middleware.`); return; } config.dev.setupMiddlewares = [ ...((_a = config.dev.setupMiddlewares) !== null && _a !== void 0 ? _a : []), (middlewares) => { middlewares.unshift(createSentrySymbolicatorMiddleware(config)); }, ]; }); } }, }; } export { pluginSentryLynx }; //# sourceMappingURL=index.mjs.map