MCPcopy
hub / github.com/webpack/webpack / applyWebpackOptionsDefaults

Function applyWebpackOptionsDefaults

lib/config/defaults.js:313–564  ·  view source on GitHub ↗
(options, compilerIndex)

Source from the content-addressed store, hash-verified

311 * @returns {ResolvedOptions} Resolved options after apply defaults
312 */
313const applyWebpackOptionsDefaults = (options, compilerIndex) => {
314 F(options, "context", () => process.cwd());
315 F(options, "target", () =>
316 getDefaultTarget(/** @type {string} */ (options.context))
317 );
318
319 const { mode, name, target } = options;
320
321 const targetProperties =
322 target === false
323 ? /** @type {false} */ (false)
324 : typeof target === "string"
325 ? getTargetProperties(target, /** @type {Context} */ (options.context))
326 : getTargetsProperties(
327 /** @type {string[]} */ (target),
328 /** @type {Context} */ (options.context)
329 );
330
331 const development = mode === "development";
332 const production = mode === "production" || !mode;
333
334 if (typeof options.entry !== "function") {
335 for (const key of Object.keys(options.entry)) {
336 F(
337 options.entry[key],
338 "import",
339 () => /** @type {[string]} */ (["./src"])
340 );
341 }
342 }
343
344 F(
345 options,
346 "devtool",
347 () =>
348 /** @type {Devtool} */ (
349 development
350 ? [
351 options.experiments.css
352 ? {
353 type: "css",
354 use: "source-map"
355 }
356 : undefined,
357 {
358 type: "javascript",
359 use: "eval"
360 }
361 ].filter(Boolean)
362 : false
363 )
364 );
365
366 D(options, "watch", false);
367 D(options, "profile", false);
368 D(options, "parallelism", 100);
369 D(options, "recordsInputPath", false);
370 D(options, "recordsOutputPath", false);

Callers

nothing calls this directly

Calls 15

getDefaultTargetFunction · 0.85
getTargetPropertiesFunction · 0.85
getTargetsPropertiesFunction · 0.85
applyExperimentsDefaultsFunction · 0.85
applyCacheDefaultsFunction · 0.85
applySnapshotDefaultsFunction · 0.85
applyOutputDefaultsFunction · 0.85
applyModuleDefaultsFunction · 0.85
applyLoaderDefaultsFunction · 0.85
applyNodeDefaultsFunction · 0.85
applyPerformanceDefaultsFunction · 0.85

Tested by

no test coverage detected