Skip to content

Commit

Permalink
add documentation for output.PreserveModulesRoot (#3792)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidroeca committed Sep 22, 2020
1 parent 1040292 commit 6a974a7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/999-big-list-of-options.md
Expand Up @@ -856,6 +856,30 @@ const main = require('./main.js');
console.log(main.default); // 42
```

#### output.preserveModulesRoot
Type: `string`<br>
CLI: `--preserveModulesRoot <directory-name>`

A directory path to input modules that should be stripped away from [`output.dir`](guide/en/#outputdir) path while [`output.preserveModules`](guide/en#outputpreservemodules) is `true`.

For example, given the following configuration:

```javascript
export default ({
input: [ 'src/module.js', `src/another/module.js` ],
output: [{
format: 'es',
dir: 'dist',
preserveModules: true,
preserveModulesRoot: 'src'
}]
});
```

The `preserveModulesRoot` setting ensures that the input modules will be output to the paths `dist/module.js` and `dist/another/module.js`.

This option is particularly useful while using plugins such as `@rollup/plugin-node-resolve`, which may cause changes in the output directory structure. This can happen when third-party modules are not marked [`external`](guide/en/#external), or while developing in a monorepo of multiple packages that rely on one another and are not marked [`external`](guide/en/#external).

#### output.sourcemap
Type: `boolean | 'inline' | 'hidden'`<br>
CLI: `-m`/`--sourcemap`/`--no-sourcemap`<br>
Expand Down

0 comments on commit 6a974a7

Please sign in to comment.