sentry上传source-map

364 阅读1分钟

nuxt项目sentry上传source-map

最新版本:

  • @nuxtjs/sentry: ^7.5.0
  • @sentry/webpack-plugin: ^2.8.0
// nuxt.config.js
import { sentryWebpackPlugin } from '@sentry/webpack-plugin'

modules: ['@nuxtjs/sentry'],
sentry: {
    dsn: '',
    config: { environment: 'production' },
},
build: {
    extend(config, { isClient }) {
        if (isProductionEnv && isClient) {
        config.devtool = 'source-map'

        config.plugins.push(
          config.plugins.push(
              sentryWebpackPlugin({
                org: '',
                project: '', // sentry中定义的项目名称
                authToken:'',
                url: 'https://sentry***.cn/', // sentry的url
                sourcemaps: {
                  assets: ['.nuxt/dist/client/*.js', '.nuxt/dist/client/*.js.map'],
                  filesToDeleteAfterUpload: ['.nuxt/dist/client/*.js.map'],
                },
                release: {
                  name: 'lanqiao-fe-release',
                  setCommits: {
                    auto: true,
                  },
                },
                errorHandler: err => {
                  console.warn(err)
                },
              })
            )
        )
      }
    }
}

参考链接:nuxt sentry source-map

vue与react项目sentry上传source-map

参考链接:基于Sentry的前端性能监控平台搭建与应用