flowbite-react
Version:
Official React components built for Flowbite and Tailwind CSS
1 lines • 4.38 kB
Source Map (JSON)
{"version":3,"file":"build.cjs","sources":["../../../src/cli/commands/build.ts"],"sourcesContent":["import fs from \"fs/promises\";\nimport { allowedExtensions, automaticClassGenerationMessage, classListFilePath, excludeDirs } from \"../consts\";\nimport { buildClassList } from \"../utils/build-class-list\";\nimport { createInitLogger } from \"../utils/create-init-logger\";\nimport { extractComponentImports } from \"../utils/extract-component-imports\";\nimport { findFiles } from \"../utils/find-files\";\nimport { getConfig } from \"../utils/get-config\";\nimport { setupInit } from \"./setup-init\";\nimport { setupOutputDirectory } from \"./setup-output-directory\";\n\nexport async function build() {\n await setupOutputDirectory();\n\n try {\n const config = await getConfig();\n await setupInit(config);\n const initLogger = createInitLogger(config);\n\n const importedComponents: string[] = [];\n\n if (config.components.length) {\n console.warn(automaticClassGenerationMessage);\n\n if (initLogger.isCustomConfig) {\n const files = await findFiles({\n patterns: allowedExtensions.map((ext) => `**/*${ext}`),\n excludeDirs,\n });\n\n for (const file of files) {\n const content = await fs.readFile(file, \"utf-8\");\n initLogger.check(file, content);\n }\n }\n } else {\n const files = await findFiles({\n patterns: allowedExtensions.map((ext) => `**/*${ext}`),\n excludeDirs,\n });\n\n for (const file of files) {\n const content = await fs.readFile(file, \"utf-8\");\n const components = extractComponentImports(content);\n initLogger.check(file, content);\n\n if (components.length) {\n importedComponents.push(...components);\n }\n }\n }\n\n initLogger.log();\n\n const classList = buildClassList({\n components: config.components.length ? config.components : [...new Set(importedComponents)],\n dark: config.dark,\n prefix: config.prefix,\n version: config.version,\n });\n\n console.log(`Generating ${classListFilePath} file...`);\n await fs.writeFile(classListFilePath, JSON.stringify(classList, null, 2));\n } catch (error) {\n console.error(`Failed to generate ${classListFilePath}:`, error);\n }\n}\n"],"names":["setupOutputDirectory","getConfig","setupInit","createInitLogger","automaticClassGenerationMessage","findFiles","allowedExtensions","excludeDirs","extractComponentImports","buildClassList","classListFilePath"],"mappings":";;;;;;;;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