MCPcopy
hub / github.com/dilanx/craco / applyLoaderOptions

Function applyLoaderOptions

packages/craco/src/lib/features/webpack/style/postcss.ts:96–119  ·  view source on GitHub ↗
(
  match: CompleteLoader,
  loaderOptions: Configure<any, BaseContext>,
  context: BaseContext
)

Source from the content-addressed store, hash-verified

94}
95
96function applyLoaderOptions(
97 match: CompleteLoader,
98 loaderOptions: Configure<any, BaseContext>,
99 context: BaseContext
100) {
101 if (isFunction(loaderOptions)) {
102 match.loader.options = loaderOptions(match.loader.options || {}, context);
103
104 if (!match.loader.options) {
105 throw new Error(
106 "craco: 'style.postcss.loaderOptions' function didn't return a loader config object."
107 );
108 }
109 } else {
110 // TODO: ensure is otherwise a plain object, if not, log an error.
111 match.loader.options = deepMergeWithArray(
112 {},
113 match.loader.options || {},
114 loaderOptions
115 );
116 }
117
118 log('Applied PostCSS loaders options.');
119}
120
121function overrideLoader(
122 match: CompleteLoader,

Callers 1

overrideLoaderFunction · 0.70

Calls 3

isFunctionFunction · 0.90
deepMergeWithArrayFunction · 0.90
logFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…