import {ProjextRollupStatsPlugin} from 'projext-plugin-rollup/src/plugins/stats/index.js'
ProjextRollupStatsPlugin
This is a Rollup plugin that shows stats on the files generated and/or copied. The way this
plugin works is kind of different: Once instantiated, it has an add
metho for registering
stats entries and that can be sent to other plugins; and at the same time, it has a log
method
that you would add as a plugin and it would show the entries.
Example:
const stats = new ProjextRollupStatsPlugin();
stats.add(...);
stats.add(...);
...
export { * plugins: [
commonjs(),
resolve(),
...,
stats.log(),
],
};
Constructor Summary
Public Constructor | ||
public |
constructor(options: ProjextRollupStatsPluginOptions, name: string) |
Method Summary
Public Methods | ||
public |
Adds a new stats entry. |
|
public |
Gets the plugin options |
|
public |
Generates a "sub plugin" to add to the plugins queue and that will take care of logging all the added entries on a report table. |
|
public |
Generates a "sub plugin" to add to the plugins queue and that will reset the entries list. |
Public Constructors
public constructor(options: ProjextRollupStatsPluginOptions, name: string) source
Params:
Name | Type | Attribute | Description |
options | ProjextRollupStatsPluginOptions |
|
The options to customize the plugin behaviour. |
name | string |
|
The name of the plugin's instance. |
Public Methods
public add(plugin: string | Promise, filepath: string, index: number) source
Adds a new stats entry.
Params:
Name | Type | Attribute | Description |
plugin | string | Promise | This can be either the name of the plugin generating the
entry, or, if the spot should be saved but the actual
entry is involved on an async task, a promise the plugin
will wait for. The promise should be resolved with an
object with the keys |
|
filepath | string |
|
The path for the file that was generatedcopied. This is
not required if |
index | number |
|
If this value is specified, instead of adding the entry to the list, it will be set at the given index. This is used internally by the plugin after resolving promise based entries, instead of adding the resolved value, the plugin replaces the entry that had the promise with the resolved information. |
public log(options: ProjextRollupStatsPluginLogOptions): ProjextRollupStatsPluginLog source
Generates a "sub plugin" to add to the plugins queue and that will take care of logging all the added entries on a report table.
Params:
Name | Type | Attribute | Description |
options | ProjextRollupStatsPluginLogOptions |
|
Custom options for the "sub plugin". |
public reset(): ProjextRollupStatsPluginReset source
Generates a "sub plugin" to add to the plugins queue and that will reset the entries list. The reason this exists is because when Rollup is on "watch mode", the plugins can run more than once, and if the queue is not reseted, the report table will show the entries for ALL the times the plugin ran.