Skip to content

sourcemapPathTransform()

  • Type: optional sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => string

A transformation to apply to each path in a sourcemap.

Parameters

relativeSourcePath

string

The relative path from the generated .map file to the corresponding source file.

sourcemapPath

string

The fully resolved path of the generated sourcemap file.

Returns

string

Example

js
export default defineConfig({
  output: {
    sourcemap: true,
    sourcemapPathTransform: (source, sourcemapPath) => {
      // Remove 'src/' prefix from all source paths
      return source.replace(/^src//, '');
    },
  },
});

Released under the MIT License.