Skip to content

Commit a2ae1ef

Browse files
authored
docs: show absolute output path usage (#716)
1 parent 9ba43c7 commit a2ae1ef

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ new BundleAnalyzerPlugin(options?: object)
7070
| **`excludeAssets`** | `{null\|pattern\|pattern[]}` where `pattern` equals to `{String\|RegExp\|function}` | Default: `null`. Patterns that will be used to match against asset names to exclude them from the report. If pattern is a string it will be converted to RegExp via `new RegExp(str)`. If pattern is a function it should have the following signature `(assetName: string) => boolean` and should return `true` to _exclude_ matching asset. If multiple patterns are provided asset should match at least one of them to be excluded. |
7171
| **`logLevel`** | One of: `info`, `warn`, `error`, `silent` | Default: `info`. Used to control how much details the plugin outputs. |
7272

73+
### Absolute output paths
74+
75+
`reportFilename` and `statsFilename` can be absolute paths. Use absolute paths when you want the generated report or stats file to be written outside webpack's `output.path`. Relative paths are resolved against the bundle output directory.
76+
77+
```js
78+
const path = require("node:path");
79+
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
80+
81+
module.exports = {
82+
plugins: [
83+
new BundleAnalyzerPlugin({
84+
analyzerMode: "static",
85+
reportFilename: path.resolve(__dirname, "reports/report.html"),
86+
generateStatsFile: true,
87+
statsFilename: path.resolve(__dirname, "reports/stats.json"),
88+
}),
89+
],
90+
};
91+
```
92+
7393
<h2 align="center">Usage (as a CLI utility)</h2>
7494

7595
You can analyze an existing bundle if you have a webpack stats JSON file.

0 commit comments

Comments
 (0)