Skip to content

Commit dafbbb2

Browse files
MagicDuckskipjack
authored andcommitted
adding docs for new output.devtoolNamespace option and [namespace] placeholder
1 parent bc804af commit dafbbb2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/content/configuration/output.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ contributors:
99
- irth
1010
- fvgs
1111
- dhurlburtusa
12+
- MagicDuck
1213
---
1314

1415
The top-level `output` key contains set of options instructing webpack on how and where it should output your bundles, assets and anything else you bundle or load with webpack.
@@ -138,7 +139,7 @@ This option is only used when [`devtool`](/configuration/devtool) uses an option
138139
Customize the names used in each source map's `sources` array. This can be done by passing a template string or function. For example, when using `devtool: 'eval'`, this is the default:
139140

140141
``` js
141-
devtoolModuleFilenameTemplate: "webpack:///[resource-path]?[loaders]"
142+
devtoolModuleFilenameTemplate: "webpack://[namespace]/[resource-path]?[loaders]"
142143
```
143144

144145
The following substitutions are available in template strings (via webpack's internal [`ModuleFilenameHelpers`](https://github.com/webpack/webpack/blob/master/lib/ModuleFilenameHelpers.js)):
@@ -152,6 +153,7 @@ The following substitutions are available in template strings (via webpack's int
152153
| [loaders] | Explicit loaders and params up to the name of the first loader |
153154
| [resource] | The path used to resolve the file and any query params used on the first loader |
154155
| [resource-path] | The path used to resolve the file without any query params |
156+
| [namespace] | The modules namespace. This is usually the library name when building as a library, empty otherwise |
155157

156158
When using a function, the same options are available camel-cased via the `info` parameter:
157159

@@ -163,6 +165,12 @@ devtoolModuleFilenameTemplate: info => {
163165

164166
If multiple modules would result in the same name, [`output.devtoolFallbackModuleFilenameTemplate`](#output-devtoolfallbackmodulefilenametemplate) is used instead for these modules.
165167

168+
## `output.devtoolNamespace`
169+
170+
`string`
171+
172+
This option determines the modules namespace used with the [`output.devtoolModuleFilenameTemplate`](#output-devtoolmodulefilenametemplate). When not specified, it will default to the value of: [`output.library`](#output-library). It's use is to prevent source file path collisions in sourcemaps when loading multiple libraries built with webpack.
173+
For example, if you have 2 libraries, with namespaces `library1` and `library2`, which both have a file `./src/index.js` (with potentially different contents), they will expose these files as `webpack://library1/./src/index.js` and `webpack://library2/./src/index.js`.
166174

167175
## `output.filename`
168176

0 commit comments

Comments
 (0)