MCPcopy Create free account
hub / github.com/jantimon/html-webpack-plugin / apply

Method apply

index.js:163–310  ·  view source on GitHub ↗

* * @param {Compiler} compiler * @returns {void}

(compiler)

Source from the content-addressed store, hash-verified

161 * @returns {void}
162 */
163 apply(compiler) {
164 this.logger = compiler.getInfrastructureLogger("HtmlWebpackPlugin");
165
166 const options = this.options;
167
168 options.template = this.getTemplatePath(
169 this.options.template,
170 compiler.context,
171 );
172
173 // Assert correct option spelling
174 if (
175 options.scriptLoading !== "defer" &&
176 options.scriptLoading !== "blocking" &&
177 options.scriptLoading !== "module" &&
178 options.scriptLoading !== "systemjs-module"
179 ) {
180 /** @type {Logger} */
181 (this.logger).error(
182 'The "scriptLoading" option need to be set to "defer", "blocking" or "module" or "systemjs-module"',
183 );
184 }
185
186 if (
187 options.inject !== true &&
188 options.inject !== false &&
189 options.inject !== "head" &&
190 options.inject !== "body"
191 ) {
192 /** @type {Logger} */
193 (this.logger).error(
194 'The `inject` option needs to be set to true, false, "head" or "body',
195 );
196 }
197
198 if (
199 this.options.templateParameters !== false &&
200 typeof this.options.templateParameters !== "function" &&
201 typeof this.options.templateParameters !== "object"
202 ) {
203 /** @type {Logger} */
204 (this.logger).error(
205 "The `templateParameters` has to be either a function or an object or false",
206 );
207 }
208
209 // Default metaOptions if no template is provided
210 if (
211 !this.userOptions.template &&
212 options.templateContent === false &&
213 options.meta
214 ) {
215 options.meta = Object.assign(
216 {},
217 options.meta,
218 {
219 // TODO remove in the next major release
220 // From https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag

Callers

nothing calls this directly

Calls 3

getTemplatePathMethod · 0.95
addEntryMethod · 0.95
generateHTMLMethod · 0.95

Tested by

no test coverage detected