MCPcopy
hub / github.com/callstack/repack / apply

Method apply

packages/repack/src/webpack/plugins/LoggerPlugin.ts:108–215  ·  view source on GitHub ↗

* Apply the plugin. * * @param compiler Webpack compiler instance.

(compiler: webpack.Compiler)

Source from the content-addressed store, hash-verified

106 * @param compiler Webpack compiler instance.
107 */
108 apply(compiler: webpack.Compiler) {
109 // Make sure webpack-cli doesn't print stats by default.
110 compiler.options.stats = 'none';
111
112 if (this.config.devServerEnabled) {
113 new webpack.ProgressPlugin((percentage, message, text) => {
114 const entry = this.createEntry('LoggerPlugin', 'info', [
115 {
116 progress: {
117 value: percentage,
118 label: message,
119 message: text,
120 platform: this.config.platform,
121 },
122 },
123 ]);
124 if (entry) {
125 this.processEntry(entry);
126 }
127 }).apply(compiler);
128 }
129
130 compiler.hooks.infrastructureLog.tap(
131 'LoggerPlugin',
132 (issuer, type, args) => {
133 const entry = this.createEntry(issuer, type, args);
134 if (entry) {
135 this.processEntry(entry);
136 }
137 return true;
138 }
139 );
140
141 compiler.hooks.thisCompilation.tap('LoggerPlugin', (compilation) => {
142 compilation.hooks.log.intercept({
143 call: (issuer, { time, type, args }) => {
144 const entry = this.createEntry(issuer, type, args, time);
145 if (entry) {
146 this.processEntry(entry);
147 }
148 },
149 });
150 });
151
152 compiler.hooks.done.tap('LoggerPlugin', (stats) => {
153 if (this.config.devServerEnabled) {
154 const { time, errors, warnings } = stats.toJson({
155 timings: true,
156 errors: true,
157 warnings: true,
158 });
159
160 let entires: Array<LogEntry | undefined> = [];
161 if (errors?.length) {
162 entires = [
163 this.createEntry('LoggerPlugin', 'error', [
164 'Failed to build bundle due to errors',
165 ]),

Callers

nothing calls this directly

Calls 5

createEntryMethod · 0.95
processEntryMethod · 0.95
flushFileLogsMethod · 0.80
stopMethod · 0.80
applyMethod · 0.65

Tested by

no test coverage detected