Skip to content

Commit

Permalink
feat(options): add filenameTemplate option
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Apr 23, 2019
1 parent b0a0355 commit 2677255
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 57 deletions.
11 changes: 11 additions & 0 deletions README.md
Expand Up @@ -342,6 +342,17 @@ module.exports = {
};
```

#### Filename Template Function

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.

```javascript
const miniCssExtractPlugin = new MiniCssExtractPlugin({
filenameTemplate: ({chunk}) =>
`${chunk.name.replace('/js/', '/css/')}.[chunkhash:8].css`
})
```

#### Long Term Caching

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

0 comments on commit 2677255

Please sign in to comment.