import { } from "../core/File"; import { Plugin } from "../core/WorkflowContext"; import { BundleProducer } from "../core/BundleProducer"; import * as path from "path"; import * as fs from "fs"; import { ensureAbsolutePath } from "../Utils"; export interface IndexPluginOptions { title?: string; bundles?: string[]; path?: string; target?: string; template?: string; } export class WebIndexPluginClass implements Plugin { constructor(public opts?: IndexPluginOptions) { } producerEnd(producer: BundleProducer) { let bundlePaths = []; producer.bundles.forEach((bundle, name) => { let pass = true; if (this.opts.bundles) { if (this.opts.bundles.indexOf(name) == -1) { pass = false; } } if (pass) { if (bundle.context.output && bundle.context.output.lastPrimaryOutput) { bundlePaths.push( path.join(this.opts.path ? this.opts.path : "/", bundle.context.output.lastPrimaryOutput.filename) ) } } }); let html = `