plugins_analyze_visualizer.js

/**
 * @file plugins/analyze/visualizer.js
 * @copyright @spmhome @_2025
 * @author Scott Meesseman @spmeesseman
 *//** */

const WpwAnalyzePlugin = require("./base");
const VisualizerPlugin = require("webpack-visualizer-plugin2");

/**
 * @augments WpwAnalyzePlugin
 */
class WpwVisualizerAnalyzePlugin extends WpwAnalyzePlugin
{
    /**
     * @param {WpwPluginOptions} options Plugin options to be applied
     */
    constructor(options)
    {
        super(options);
        this.buildOptions = /** @type {WpwVisualizerAnalyzePluginOptions} */(this.buildOptions);
    }

    /**
     * @override
     * @static
     */
    static create = WpwVisualizerAnalyzePlugin.wrap.bind(this);

    /**
     * @override
     * @returns {WpwPluginTapOptions<any, any, boolean> | void}
     */
    onApply() {}

	/**
	 * @override
     * @param {WebpackCompiler} _compiler
     * @param {boolean} [applyFirst]
	 * @returns {WebpackPluginInstance | undefined}
	 */
	getVendorPlugin(_compiler, applyFirst)
	{
		if (!applyFirst) {
			return new VisualizerPlugin({ filename: "../.coverage/visualizer.html" });
		}
	}
}


module.exports = WpwVisualizerAnalyzePlugin.create;