To remove the "../src/components" path from the sourcemap generated using Rollup, you can use the sourcemapPathTransform option provided by the Rollup plugin that generates sourcemaps (e.g., rollup-plugin-sourcemaps or @rollup/plugin-sourcemaps).

The sourcemapPathTransform option allows you to modify the paths in the sourcemap. You can use it to remove the unwanted part of the path and replace it with something else or leave it empty.

Here's an example of how to configure the sourcemapPathTransform option in your Rollup configuration file (rollup.config.js):

import { terser } from 'rollup-plugin-terser'; import sourcemaps from 'rollup-plugin-sourcemaps'; export default { input: 'src/main.js', output: { file: 'dist/bundle.js', format: 'iife', sourcemap: true, }, plugins: [ // Other plugins... terser(), sourcemaps({ // Custom sourcemap path transform function sourcemapPathTransform: (relativeSourcePath, sourcemapPath) => { // Replace "../src/components" with an empty string return relativeSourcePath.replace('../src/components', ''); }, }), ], };

In this example, we use the sourcemapPathTransform function to remove the "../src/components" part from the sourcemap's paths.

Adjust the path replacement logic inside the sourcemapPathTransform function to suit your specific needs. You can remove a different part of the path or replace it with a custom string if desired.

Note that the actual name and options of the sourcemap plugin may vary depending on the version and specific Rollup plugins you are using. The example above assumes you have rollup-plugin-sourcemaps installed, but other plugins may have slightly different configurations or options. Check the documentation of your specific sourcemap plugin for more details on how to use the sourcemapPathTransform option.

Have questions or queries?
Get in Touch