Skip to content

Commit 2677255

Browse files
committed
feat(options): add filenameTemplate option
1 parent b0a0355 commit 2677255

File tree

7 files changed

+97
-57
lines changed

7 files changed

+97
-57
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,17 @@ module.exports = {
342342
};
343343
```
344344

345+
#### Filename Template Function
346+
347+
With the `filenameTemplate` option you can use chunk data to customize the filename. This is particularly useful when dealing with multiple entry points and wanting to get more control out of the filename for a given entry point/chunk. In the example below, we'll use `filenameTemplate` to output the generated css into a different directory.
348+
349+
```javascript
350+
const miniCssExtractPlugin = new MiniCssExtractPlugin({
351+
filenameTemplate: ({chunk}) =>
352+
`${chunk.name.replace('/js/', '/css/')}.[chunkhash:8].css`
353+
})
354+
```
355+
345356
#### Long Term Caching
346357

347358
For long term caching use `filename: "[contenthash].css"`. Optionally add `[name]`.

0 commit comments

Comments
 (0)