[Sentry Webpack] Rewrite URL to remove middle portion

I’m trying to rewrite the mapping URL for Sentry to find the sourcemaps correctly.

Our JS is stored in:

  • <URL>/<STAGE>/client/<FILES>
  • (Production has <STAGE> removed)

Our webpack build step outputs to dist, but when we upload to our CDN it gets moved and dist is no longer in the path.

We have the config:

new SentryWebpackPlugin({
        include: ".",
        ignore: ["node_modules", "webpack.config.js"],
        urlPrefix: '<URL INCLUDING STAGE>/client',
        stripPrefix: ['dist'],
      })

But the source maps get mapped to:

  • <URL>/<STAGE>/client/dist/<FILES>

How do we get rid of dist using the Webpack plugin? Or do I give up on the webpack plugin and just use the CLI?

tldr;

  • We want: <URL>/<STAGE>/client/<FILES>
  • We get: <URL>/<STAGE>/client/dist/<FILES>

Changed the config to look like this:

new SentryWebpackPlugin({
    include: "./dist/",
    ignore: ["node_modules", "webpack.config.js"],
    urlPrefix: '<URL INCLUDING STAGE>/client'
})

And that resolved my issue (by using the dist directory as root). It also appear that stripPrefix does nothing according to issues on the Sentry CLI & Sentry Webpack Githubs.