---
title: "Source Map"
locale: "en"
version: "current"
canonicalUrl: "https://farmfe.org/docs/features/sourcemap"
publicationStatus: "prerelease"
---

<a id="source-map"></a>
# Source Map


Farm supports ` Source Map `. Sourcemap is enabled by default in development mode and disabled by default in build/production mode. It can be ` enable ` or ` disable ` via the [` compilation.sourcemap `](</docs/config/compilation-options#sourcemap>) option.



> [!NOTE]
> note
> 
> Farm will not generate sourcemap for files under ` node_modules ` by default, if you want to generate sourcemap for files under node\_modules, configure ` compilation.sourcemap ` to ` all `.



Using ` compilation.sourcemap ` to configuring sourcemap generation:


```ts
export default {
   compilation: {
     sourcemap: 'all', // generate sourcemap for modules under node_modules
   },
};
```


All options are as below:


- **` true `**: Only generate sourcemap for files not under ` node_modules `, and generate a **separate sourcemap file**
- **` false `**: disable sourcemap
- **` inline `**: Only generate sourcemap for files not under ` node_modules `, and inline sourcemap into the product, do not generate a separate file
- **` all `**: generate sourcemap for all files, and generate a separate sourcemap file
- **` all-inline `**: Generate source maps for all files, and inline source maps into the product, do not generate separate files



> [!NOTE]
> note
> 
> For plugin authors, if you transform code in the [` transform ` hook](</docs/api/rust-plugin-api#transform>), [` render_resource_pot ` hook](</docs/api/rust-plugin-api#render_resource_pot>), or [` process_rendered_resource_pot ` hook](</docs/api/rust-plugin-api#process_rendered_resource_pot>), return the source map of your transformation to keep source maps correct. Farm maintains a **source map chain** of plugins to trace the final resources back to the real original code.
