Skip to content

Commit 053f102

Browse files
committed
Update readme section on multiple reports
1 parent 0c69f6a commit 053f102

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,39 @@ That means it won't account for post-processing from other plugins and also won'
229229

230230
Rollup allows you to output to multiple files. If you are outputting to multiple files you will get a distinct analysis for each output file. Each analysis will contain data on the files imported by the respective target.
231231

232+
One way to manipulate the number of reports in this scenario is through the `onAnalysis` callback option:
233+
234+
```js
235+
// Track iterations over output files
236+
let analyzePluginIterations = 0;
237+
238+
export default {
239+
input: 'myIsomorphicModule.js',
240+
output: [
241+
{
242+
name: 'myIsomorphicModule',
243+
format: 'cjs',
244+
entryFileNames: '[name].cjs'
245+
},
246+
{
247+
name: 'myIsomorphicModule',
248+
format: 'es',
249+
entryFileNames: '[name].mjs'
250+
}
251+
],
252+
plugins: [
253+
analyze({
254+
onAnalysis: () => {
255+
if (analyzePluginIterations > 0) {
256+
throw ''; // We only want reports on the first output
257+
}
258+
analyzePluginIterations++;
259+
}
260+
})
261+
]
262+
}
263+
```
264+
232265
## License
233266

234267
MIT © [Andrew Carpenter](https://github.com/doesdev)

0 commit comments

Comments
 (0)