Skip to content

Commit 20cc4fa

Browse files
fix(qwik-nx): use globs util to generate tailwind paths (#229)
closes #171
1 parent 74c9605 commit 20cc4fa

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

packages/qwik-nx/src/generators/setup-tailwind/files/tailwind.config.js__tmpl__

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
const { createGlobPatternsForDependencies } = require('qwik-nx/tailwind');
12
const { join } = require('path');
23

34
/** @type {import('tailwindcss').Config} */
45
module.exports = {
56
content: [
67
join(
78
__dirname,
8-
'src/**/*.{js,ts,jsx,tsx,mdx}'
9+
'{src,pages,components,app}/**/*!(*.stories|*.spec).{ts,tsx,html}'
910
),
11+
...createGlobPatternsForDependencies(__dirname),
1012
],
1113
theme: {
1214
extend: {},
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { createGlobPatternsForDependencies as jsGenerateGlobs } from '@nx/js/src/utils/generate-globs';
2+
3+
/**
4+
* Generates a set of glob patterns based off the source root of the app and its dependencies
5+
* @param dirPath workspace relative directory path that will be used to infer the parent project and dependencies
6+
* @param fileGlobPattern pass a custom glob pattern to be used
7+
*/
8+
export function createGlobPatternsForDependencies(
9+
dirPath: string,
10+
fileGlobPattern = '/**/*!(*.stories|*.spec).{tsx,ts,jsx,js,html}'
11+
) {
12+
try {
13+
return jsGenerateGlobs(dirPath, fileGlobPattern);
14+
} catch (e) {
15+
/**
16+
* It should not be possible to reach this point when the utility is invoked as part of the normal
17+
* lifecycle of Nx executors. However, other tooling, such as the VSCode Tailwind IntelliSense plugin
18+
* or JetBrains editors such as WebStorm, may execute the tailwind.config.js file in order to provide
19+
* autocomplete features, for example.
20+
*
21+
* In order to best support that use-case, we therefore do not hard error when the ProjectGraph is
22+
* fundamently unavailable in this tailwind-specific context.
23+
*/
24+
console.warn(
25+
'\nWARNING: There was an error creating glob patterns, returning an empty array\n' +
26+
`${(e as Error).message}\n`
27+
);
28+
return [];
29+
}
30+
}

packages/qwik-nx/storybook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './src/utils/storybook';
1+
export * from './src/utils/exportable/storybook';

packages/qwik-nx/tailwind.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './src/utils/exportable/tailwind';

0 commit comments

Comments
 (0)