Skip to content

Commit 2b1c304

Browse files
Jake Todaroskipjack
authored andcommitted
docs(config): add functions as valid output.filename type (#1751)
This change corresponds to the following PR: webpack/webpack#6144
1 parent 7cddb07 commit 2b1c304

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/content/configuration/output.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ auxiliaryComment: {
6464

6565
## `output.chunkFilename`
6666

67-
`string`
67+
`string` `function`
6868

6969
This option determines the name of non-entry chunk files. See [`output.filename`](#output-filename) option for details on the possible values.
7070

@@ -166,7 +166,7 @@ If multiple modules would result in the same name, [`output.devtoolFallbackModul
166166

167167
## `output.filename`
168168

169-
`string`
169+
`string` `function`
170170

171171
This option determines the name of each output bundle. The bundle is written to the directory specified by the [`output.path`](#output-path) option.
172172

@@ -206,7 +206,7 @@ Make sure to read the [Caching guide](/guides/caching) for details. There are mo
206206

207207
Note this option is called filename but you are still allowed to use something like `"js/[name]/bundle.js"` to create a folder structure.
208208

209-
Note this options does not affect output files for on-demand-loaded chunks. For these files the [`output.chunkFilename`](#output-chunkfilename) option is used. It also doesn't affect files created by loaders. For these files see loader options.
209+
Note this option does not affect output files for on-demand-loaded chunks. For these files the [`output.chunkFilename`](#output-chunkfilename) option is used. Files created by loaders also aren't affected. In this case you would have to try the specific loader's available options.
210210

211211
The following substitutions are available in template strings (via webpack's internal [`TemplatedPathPlugin`](https://github.com/webpack/webpack/blob/master/lib/TemplatedPathPlugin.js)):
212212

@@ -220,6 +220,8 @@ The following substitutions are available in template strings (via webpack's int
220220

221221
The lengths of `[hash]` and `[chunkhash]` can be specified using `[hash:16]` (defaults to 20). Alternatively, specify [`output.hashDigestLength`](#output-hashdigestlength) to configure the length globally.
222222

223+
If using a function for this option, the function will be passed an object containing the substitutions in the table above.
224+
223225
T> When using the [`ExtractTextWebpackPlugin`](/plugins/extract-text-webpack-plugin), use `[contenthash]` to obtain a hash of the extracted file (neither `[hash]` nor `[chunkhash]` work).
224226

225227

@@ -245,7 +247,7 @@ An optional salt to update the hash via Node.JS' [`hash.update`](https://nodejs.
245247

246248
## `output.hotUpdateChunkFilename`
247249

248-
`string`
250+
`string` `function`
249251

250252
Customize the filenames of hot update chunks. See [`output.filename`](#output-filename) option for details on the possible values.
251253

@@ -271,7 +273,7 @@ For details see [`output.jsonpFunction`](#output-jsonpfunction).
271273

272274
## `output.hotUpdateMainFilename`
273275

274-
`string`
276+
`string` `function`
275277

276278
Customize the main hot update filename. See [`output.filename`](#output-filename) option for details on the possible values.
277279

@@ -607,7 +609,7 @@ Note it also adds some info about tree shaking to the generated bundle.
607609
608610
## `output.publicPath`
609611
610-
`string`
612+
`string` `function`
611613

612614
This is an important option when using on-demand-loading or loading external resources like images, files, etc. If an incorrect value is specified you'll receive 404 errors while loading these resources.
613615

0 commit comments

Comments
 (0)