MCPcopy
hub / github.com/webpack/webpack / apply

Function apply

test/configCases/module/circular-externals/webpack.config.js:30–64  ·  view source on GitHub ↗
(compiler)

Source from the content-addressed store, hash-verified

28 plugins: [
29 {
30 apply(compiler) {
31 compiler.hooks.thisCompilation.tap(
32 "copy-external-files",
33 (compilation) => {
34 compilation.hooks.processAssets.tap(
35 {
36 name: "copy-external-files",
37 stage:
38 compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL
39 },
40 () => {
41 // Read the external module files
42 const externalA = fs.readFileSync(
43 path.join(__dirname, "external-a.mjs"),
44 "utf8"
45 );
46 const externalB = fs.readFileSync(
47 path.join(__dirname, "external-b.mjs"),
48 "utf8"
49 );
50
51 // Emit them as assets
52 compilation.emitAsset(
53 "external-a.mjs",
54 new compiler.webpack.sources.RawSource(externalA)
55 );
56 compilation.emitAsset(
57 "external-b.mjs",
58 new compiler.webpack.sources.RawSource(externalB)
59 );
60 }
61 );
62 }
63 );
64 }
65 }
66 ]
67};

Callers

nothing calls this directly

Calls 2

tapMethod · 0.80
emitAssetMethod · 0.80

Tested by

no test coverage detected