使用WebPack的Serverless项目集成Sentry后无源代码上下文问题
Serverless Webpack项目集成Sentry后无法预览源代码
我在基于WebPack的Serverless项目中集成了Sentry,目前能在Sentry控制台看到错误信息,但没法像Python项目那样直接预览源代码。想请教下是否可以把源代码嵌入到Sentry中?我查了Sentry官方文档,没找到解决办法。
错误截图:
已做的配置调整
我刚在tsconfig.json里加了inlineSources: true,完整配置如下:
{ "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "lib": ["es2023", "dom"], "module": "commonjs", "skipLibCheck": true, "sourceMap": true, "inlineSources": true, "strict": true, "target": "es2023", "paths": { "~/*": ["./app/*"] } } }
我已经生成了对应的sourcemap文件,WebPack的配置如下:
/* global __dirname */ /* global module */ /* global require */ /* eslint-disable @typescript-eslint/no-require-imports */ const path = require("path"); const slsw = require("serverless-webpack"); const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin"); const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin"); const nodeExternals = require("webpack-node-externals"); const CopyPlugin = require("copy-webpack-plugin"); const { sentryWebpackPlugin } = require("@sentry/webpack-plugin"); /** @type { import('webpack').Configuration } */ module.exports = { mode: slsw.lib.webpack.isLocal ? "development" : "production", entry: slsw.lib.entries, // devtool: slsw.lib.webpack.isLocal ? 'source-map' : 'cheap-source-map', devtool: "source-map", target: "node", resolve: { extensions: [".ts"], // we just need TypeScript plugins: [new TsconfigPathsPlugin()], }, output: { libraryTarget: "commonjs2", path: path.join(__dirname, ".webpack"), filename: "[name].js", }, externals: ["aws-sdk", nodeExternals()], module: { rules: [ { test: /\.ts$/, loader: "ts-loader", exclude: [ /node_modules/, path.resolve(__dirname, ".webpack"), path.resolve(__dirname, ".serverless"), ], options: { transpileOnly: true, experimentalFileCaching: true, }, }, ], }, plugins: [ new ForkTsCheckerWebpackPlugin(), new CopyPlugin({ patterns: [{ from: "google.json", to: "google.json" }] }), sentryWebpackPlugin({ org: "zoomies", project: "serverless", authToken: process.env.SENTRY_AUTH_TOKEN, telemetry: false, }), ], };
内容的提问来源于stack exchange,提问作者Rodrigo
相关产品推荐
相关产品推荐

