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

Function apply

test/configCases/css/runtime-data-webpack/webpack.config.js:12–36  ·  view source on GitHub ↗
(compiler)

Source from the content-addressed store, hash-verified

10 plugins: [
11 {
12 apply(compiler) {
13 compiler.hooks.compilation.tap("Test", (compilation) => {
14 compilation.hooks.processAssets.tap(
15 {
16 name: "Test",
17 stage:
18 compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
19 },
20 (assets) => {
21 const name = "bundle0.css";
22 const code = /** @type {string} */ (assets[name].source());
23
24 compilation.updateAsset(
25 name,
26 new compiler.webpack.sources.RawSource(
27 `${code.replace(
28 "head{",
29 ".class, head, body{"
30 )}\n\n.after-head { color: red; }`
31 )
32 );
33 }
34 );
35 });
36 }
37 }
38 ],
39 experiments: {

Callers

nothing calls this directly

Calls 4

tapMethod · 0.80
sourceMethod · 0.80
updateAssetMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected