Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): support string as plugin option i…
Browse files Browse the repository at this point in the history
…n custom postcss plugin config

In certain cases, the plugin option may be a string value, as shown in the example below:

```json
{
 "plugins": {
  "tailwindcss/nesting": "postcss-nesting"
  }
}
```

In certain cases, the plugin option may be a string value, as shown in the example below:

```json
{
 "plugins": {
  "tailwindcss/nesting": "postcss-nesting"
  }
}
```

See: https://tailwindcss.com/docs/using-with-preprocessors#nesting
(cherry picked from commit 6e8d326)
  • Loading branch information
alan-agius4 committed Feb 14, 2024
1 parent d493609 commit 905e136
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { readFile, readdir } from 'node:fs/promises';
import { join } from 'node:path';

export interface PostcssConfiguration {
plugins: [name: string, options?: object][];
plugins: [name: string, options?: object | string][];
}

interface RawPostcssConfiguration {
plugins?: Record<string, object | boolean> | (string | [string, object])[];
plugins?: Record<string, object | boolean | string> | (string | [string, object])[];
}

const postcssConfigurationFiles: string[] = ['postcss.config.json', '.postcssrc.json'];
Expand Down Expand Up @@ -104,7 +104,7 @@ export async function loadPostcssConfiguration(

const config: PostcssConfiguration = { plugins: [] };
for (const [name, options] of entries) {
if (!options || typeof options !== 'object') {
if (!options || (typeof options !== 'object' && typeof options !== 'string')) {
continue;
}

Expand Down

0 comments on commit 905e136

Please sign in to comment.