Skip to content

Commit

Permalink
feat(angular): support tailwind.config.cjs as valid config file in li…
Browse files Browse the repository at this point in the history
…brary executors (#10531)
  • Loading branch information
leosvelperez committed May 31, 2022
1 parent 20a509d commit c6af229
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions packages/angular/src/executors/utilities/tailwindcss.ts
Expand Up @@ -25,15 +25,7 @@ export function getTailwindSetup(
let tailwindConfigPath = tailwindConfig;

if (!tailwindConfigPath) {
// Try to find TailwindCSS configuration file in the project or workspace root.
const tailwindConfigFile = 'tailwind.config.js';
for (const path of [basePath, workspaceRoot]) {
const fullPath = join(path, tailwindConfigFile);
if (existsSync(fullPath)) {
tailwindConfigPath = fullPath;
break;
}
}
tailwindConfigPath = getTailwindConfigPath(basePath, workspaceRoot);
}

// Only load Tailwind CSS plugin if configuration file was found.
Expand Down Expand Up @@ -65,6 +57,25 @@ export function getTailwindSetup(
return { tailwindConfigPath, tailwindPackagePath };
}

function getTailwindConfigPath(
projectRoot: string,
workspaceRoot: string
): string | undefined {
// valid tailwind config files https://github.com/tailwindlabs/tailwindcss/blob/master/src/util/resolveConfigPath.js#L46
const tailwindConfigFiles = ['tailwind.config.js', 'tailwind.config.cjs'];

for (const basePath of [projectRoot, workspaceRoot]) {
for (const configFile of tailwindConfigFiles) {
const fullPath = join(basePath, configFile);
if (existsSync(fullPath)) {
return fullPath;
}
}
}

return undefined;
}

export function getTailwindPostCssPlugins(
{ tailwindConfigPath, tailwindPackagePath }: TailwindSetup,
includePaths?: string[],
Expand Down

0 comments on commit c6af229

Please sign in to comment.