MCPcopy Index your code
hub / github.com/webpack/css-loader / getModulesOptions

Function getModulesOptions

src/utils.js:497–665  ·  view source on GitHub ↗
(rawOptions, esModule, exportType, loaderContext)

Source from the content-addressed store, hash-verified

495const IS_ICSS = /\.icss\.\w+$/i;
496
497function getModulesOptions(rawOptions, esModule, exportType, loaderContext) {
498 if (typeof rawOptions.modules === "boolean" && rawOptions.modules === false) {
499 return false;
500 }
501
502 const resourcePath =
503 // eslint-disable-next-line no-underscore-dangle
504 (loaderContext._module && loaderContext._module.matchResource) ||
505 loaderContext.resourcePath;
506
507 let auto;
508 let rawModulesOptions;
509
510 if (typeof rawOptions.modules === "undefined") {
511 rawModulesOptions = {};
512 auto = true;
513 } else if (typeof rawOptions.modules === "boolean") {
514 rawModulesOptions = {};
515 } else if (typeof rawOptions.modules === "string") {
516 rawModulesOptions = { mode: rawOptions.modules };
517 } else {
518 rawModulesOptions = rawOptions.modules;
519 ({ auto } = rawModulesOptions);
520 }
521
522 const needNamedExport =
523 exportType === "css-style-sheet" || exportType === "string";
524 const namedExport =
525 typeof rawModulesOptions.namedExport !== "undefined"
526 ? rawModulesOptions.namedExport
527 : needNamedExport || esModule;
528 const exportLocalsConvention =
529 typeof rawModulesOptions.exportLocalsConvention !== "undefined"
530 ? rawModulesOptions.exportLocalsConvention
531 : namedExport
532 ? "as-is"
533 : "camel-case-only";
534 const modulesOptions = {
535 auto,
536 mode: "local",
537 exportGlobals: false,
538 localIdentName: "[hash:base64]",
539 localIdentContext: loaderContext.rootContext,
540 // eslint-disable-next-line no-underscore-dangle
541 localIdentHashSalt:
542 loaderContext.hashSalt ||
543 // TODO remove in the next major release
544 // eslint-disable-next-line no-underscore-dangle
545 loaderContext._compilation.outputOptions.hashSalt,
546 localIdentHashFunction:
547 loaderContext.hashFunction ||
548 // TODO remove in the next major release
549 // eslint-disable-next-line no-underscore-dangle
550 loaderContext._compilation.outputOptions.hashFunction,
551 localIdentHashDigest:
552 loaderContext.hashDigest ||
553 // TODO remove in the next major release
554 // eslint-disable-next-line no-underscore-dangle

Callers 1

normalizeOptionsFunction · 0.85

Calls 2

camelCaseFunction · 0.85
dashesCamelCaseFunction · 0.85

Tested by

no test coverage detected