Skip to content

Commit c7c7d85

Browse files
committed
fix: add watcher for config file too and generate fresh class list on changes
1 parent c702792 commit c7c7d85

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

packages/ui/src/cli/consts.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const excludeDirs = [
1818
"node_modules",
1919
"out",
2020
"storybook-static",
21-
outputDir,
2221
];
2322

2423
export const defaultConfig: Config = {

packages/ui/src/cli/index.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export async function dev() {
5151

5252
if (config.components.length) {
5353
console.warn(automaticClassGenerationMessage);
54-
return;
5554
}
5655

5756
const importedComponentsMap: Record<string, string[]> = {};
@@ -77,7 +76,7 @@ export async function dev() {
7776
const config = await getConfig();
7877
const newClassList = buildClassList({
7978
prefix: config.prefix,
80-
components: newImportedComponents,
79+
components: config.components.length ? config.components : newImportedComponents,
8180
});
8281

8382
if (!isEqual(classList, newClassList)) {
@@ -92,7 +91,7 @@ export async function dev() {
9291
return excludeDirs.some((dir) => path.endsWith(dir));
9392
}
9493
if (stats?.isFile()) {
95-
return ![".astro", ".js", ".jsx", ".md", ".mdx", ".ts", ".tsx"].some((type) => path.endsWith(type));
94+
return ![".astro", ".js", ".jsx", ".md", ".mdx", ".ts", ".tsx", configFile].some((type) => path.endsWith(type));
9695
}
9796
return false;
9897
},
@@ -520,6 +519,12 @@ async function generateClassList() {
520519
}
521520

522521
export async function register() {
522+
const config = await getConfig();
523+
524+
if (config.components.length) {
525+
console.warn(automaticClassGenerationMessage);
526+
}
527+
523528
try {
524529
// clean up old process
525530
const pid = await fs.readFile(`${outputDir}/${processIdFile}`, "utf8");
@@ -529,13 +534,6 @@ export async function register() {
529534
//
530535
}
531536

532-
const config = await getConfig();
533-
534-
if (config.components.length) {
535-
console.warn(automaticClassGenerationMessage);
536-
return;
537-
}
538-
539537
try {
540538
// run `flowbite-react dev` in background
541539
const devProcess = spawn("flowbite-react", ["dev"], {

0 commit comments

Comments
 (0)