(
match: CompleteLoader,
{ postcss: postcssOptions }: CracoStyleConfig
)
| 46 | } |
| 47 | |
| 48 | function extendsPostcss( |
| 49 | match: CompleteLoader, |
| 50 | { postcss: postcssOptions }: CracoStyleConfig |
| 51 | ) { |
| 52 | const { plugins, env } = postcssOptions ?? {}; |
| 53 | if (isArray(plugins) || env) { |
| 54 | let postcssPlugins: any[]; |
| 55 | |
| 56 | if (env) { |
| 57 | const mergedPreset = deepMergeWithArray({}, CRA_PRESET_ENV, env); |
| 58 | postcssPlugins = CRA_PLUGINS(mergedPreset); |
| 59 | |
| 60 | log('Merged PostCSS env preset.'); |
| 61 | } else { |
| 62 | let craPlugins: any[] = []; |
| 63 | |
| 64 | if (!isString(match.loader.options)) { |
| 65 | const options = match.loader.options?.postcssOptions; |
| 66 | if (isFunction(options)) { |
| 67 | craPlugins = options().plugins; |
| 68 | } else { |
| 69 | craPlugins = options?.plugins; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | postcssPlugins = craPlugins || []; |
| 74 | } |
| 75 | |
| 76 | if (plugins) { |
| 77 | postcssPlugins = isFunction(plugins) |
| 78 | ? plugins(postcssPlugins) |
| 79 | : postcssPlugins.concat(plugins); |
| 80 | |
| 81 | log('Added PostCSS plugins.'); |
| 82 | } |
| 83 | |
| 84 | if (match.loader.options && !isString(match.loader.options)) { |
| 85 | if (match.loader.options.postcssOptions) { |
| 86 | match.loader.options.postcssOptions.plugins = () => postcssPlugins; |
| 87 | } else { |
| 88 | match.loader.options.postcssOptions = { |
| 89 | plugins: () => postcssPlugins, |
| 90 | }; |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | function applyLoaderOptions( |
| 97 | match: CompleteLoader, |
no test coverage detected
searching dependent graphs…