title: Sentry: Upload sourcemaps from folder tree
body: <p>I'm working with a NextJs/ReactJs (with Typescript) application and I'm trying to upload the sourcemaps to Sentry artefacts.</p>
  
  <p>The build from this app is not bundled to a single file.
  Instead, the dist/output folder reflects the NextJs pages structure, which in this case has a tree structure similar to this:</p>
  
  <pre><code>.next
  |__ static
     |__ buildId
        |__ app.js
        |__ _app.js.map
        |__ index.js
        |__ index.js.map
        |__ customer
           |__ [customerId]
              |__ details.js
              |__ details.js.map
              |__ sub folder 1
              |__  sub folder 2
  </code></pre>
  
  <p>All the .js files reference a .map file. For example, in <code>/.next/static/buildId/index.js</code>, the last line is <code>//# sourceMappingURL=index.js.map</code>.</p>
  
  <p>Then, I'm uploading sourcemaps to Sentry with the following command:</p>
  
  <pre><code>docker exec -it wtr-admin_app_container yarn sentry-cli 
    --auth-token=${SENTRY_AUTH_TOKEN} releases
    --org=${SENTRY_ORGANIZATION}
    --project=${SENTRY_PROJECT} files ${VERSION} upload-sourcemaps "./src/.next/static/" 
    --url-prefix "~/_next/static/" 
    --no-rewrite
  </code></pre>
  
  <p>The problem is about that <code>--url-prefix</code>, which should be <code>~/_next/static/buildId/</code> for <code>/.next/static/buildId/index.js</code> file but should be <code>~/_next/static/buildId/customer/[customerId]/</code> for <code>/.next/static/buildId/customer/[customerId]/details.js</code> file.</p>
  
  <p>So, uploading all files under the same url-prefix won't work properly.</p>
  
  <hr>
  
  <p><strong>Is there any way of uploading this tree structure in a way where the .js files are correctly associated with its .map files?</strong></p>
  
  <p><strong>Is <a href="https://docs.sentry.io/platforms/javascript/#rewriteframes" rel="nofollow noreferrer">RewriteFrames</a> an option for this use case?</strong></p>
  
  <hr>