UNPKG

@serwist/webpack-plugin

Version:

A plugin for your webpack build process, helping you generate a manifest of local files that should be precached.

1 lines 1.74 kB
{"version":3,"file":"index.internal.mjs","names":[],"sources":["../src/lib/child-compilation-plugin.ts"],"sourcesContent":["import type { Compiler, WebpackError, WebpackPluginInstance } from \"webpack\";\nimport { performChildCompilation } from \"./perform-child-compilation.js\";\nimport { relativeToOutputPath } from \"./relative-to-output-path.js\";\n\nexport interface ChildCompilationPluginOptions {\n src: string;\n dest: string;\n plugins?: WebpackPluginInstance[];\n}\n\n/**\n * Compile a file by creating a child of the hooked compiler.\n *\n * @private\n */\nexport class ChildCompilationPlugin implements WebpackPluginInstance {\n src: string;\n dest: string;\n plugins: WebpackPluginInstance[] | undefined;\n constructor({ src, dest, plugins }: ChildCompilationPluginOptions) {\n this.src = src;\n this.dest = dest;\n this.plugins = plugins;\n }\n /**\n * @param compiler default compiler object passed from webpack\n *\n * @private\n */\n apply(compiler: Compiler) {\n compiler.hooks.make.tapPromise(this.constructor.name, (compilation) =>\n performChildCompilation(\n compiler,\n compilation,\n this.constructor.name,\n this.src,\n relativeToOutputPath(compilation, this.dest),\n this.plugins,\n ).catch((error: WebpackError) => {\n compilation.errors.push(error);\n }),\n );\n }\n}\n"],"mappings":";;;;;;;AAeA,IAAa,yBAAb,MAAqE;CACnE;CACA;CACA;CACA,YAAY,EAAE,KAAK,MAAM,WAA0C;AACjE,OAAK,MAAM;AACX,OAAK,OAAO;AACZ,OAAK,UAAU;;;;;;;CAOjB,MAAM,UAAoB;AACxB,WAAS,MAAM,KAAK,WAAW,KAAK,YAAY,OAAO,gBACrD,wBACE,UACA,aACA,KAAK,YAAY,MACjB,KAAK,KACL,qBAAqB,aAAa,KAAK,KAAK,EAC5C,KAAK,QACN,CAAC,OAAO,UAAwB;AAC/B,eAAY,OAAO,KAAK,MAAM;IAC9B,CACH"}