MCPcopy
hub / github.com/smapiot/piral / apply

Method apply

src/tooling/piral-cli-webpack5/src/plugins/SheetPlugin.ts:16–46  ·  view source on GitHub ↗
(compiler: Compiler)

Source from the content-addressed store, hash-verified

14 }
15
16 apply(compiler: Compiler) {
17 const { entry } = compiler.options;
18
19 entry[this.entryName].import = [this.loaderPath, ...entry[this.entryName].import];
20
21 compiler.hooks.compilation.tap('SheetPlugin', (compilation: Compilation) => {
22 if (!compilation.compiler.parentCompilation) {
23 compilation.hooks.processAssets.tap(
24 {
25 name: 'SheetPlugin',
26 stage: Compilation.PROCESS_ASSETS_STAGE_REPORT,
27 },
28 () => {
29 const cssExists = !!compilation.getAsset(this.cssName);
30
31 if (!cssExists) {
32 // locate target asset
33 const targetName = `${this.entryName}.js`;
34 const asset = compilation.getAsset(targetName);
35
36 if (asset) {
37 const source = asset.source.source().toString();
38 const updated = source.replace('window.__NO_CSS__', 'true');
39 compilation.updateAsset(targetName, new RawSource(updated));
40 }
41 }
42 },
43 );
44 }
45 });
46 }
47}

Callers 4

system.tsFile · 0.45
prepareForStartupFunction · 0.45
cbFunction · 0.45
logFunction · 0.45

Calls 2

toStringMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected