prepare-config.ts — tailwindcss Source File
Architecture documentation for prepare-config.ts, a typescript file in the tailwindcss codebase. 16 imports, 2 dependents.
Entity Profile
Dependency Diagram
graph LR c8809718_3b35_1fdb_ff99_94e375c7360a["prepare-config.ts"] 69d3ce9e_56db_8f40_5261_64f91b0dee31["compile.ts"] c8809718_3b35_1fdb_ff99_94e375c7360a --> 69d3ce9e_56db_8f40_5261_64f91b0dee31 0dec976b_4cf5_63bb_0d29_f560fe197a3b["loadModule"] c8809718_3b35_1fdb_ff99_94e375c7360a --> 0dec976b_4cf5_63bb_0d29_f560fe197a3b 9b5d2e3d_392e_c654_c350_1352ed70f5e8["resolve-config.ts"] c8809718_3b35_1fdb_ff99_94e375c7360a --> 9b5d2e3d_392e_c654_c350_1352ed70f5e8 0ed24ba5_7c39_3f5a_fdbb_f973a617a172["resolveConfig"] c8809718_3b35_1fdb_ff99_94e375c7360a --> 0ed24ba5_7c39_3f5a_fdbb_f973a617a172 af1a6ece_0432_a556_fd63_8cb4a91f12ad["plugin-api.ts"] c8809718_3b35_1fdb_ff99_94e375c7360a --> af1a6ece_0432_a556_fd63_8cb4a91f12ad 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a["design-system.ts"] c8809718_3b35_1fdb_ff99_94e375c7360a --> 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a 9106c15d_cfb8_77f5_665e_9707020b48c8["renderer.ts"] c8809718_3b35_1fdb_ff99_94e375c7360a --> 9106c15d_cfb8_77f5_665e_9707020b48c8 f1ca9393_701c_e4a7_8303_ed03f028d19b["error"] c8809718_3b35_1fdb_ff99_94e375c7360a --> f1ca9393_701c_e4a7_8303_ed03f028d19b a81de696_6bb5_40db_26ca_1d707ccebed9["highlight"] c8809718_3b35_1fdb_ff99_94e375c7360a --> a81de696_6bb5_40db_26ca_1d707ccebed9 efdaf4fe_1cde_66e0_60e0_5e155e297f6d["relative"] c8809718_3b35_1fdb_ff99_94e375c7360a --> efdaf4fe_1cde_66e0_60e0_5e155e297f6d d13948d4_4434_bf78_9916_1ba327123c94["migrate-prefix.ts"] c8809718_3b35_1fdb_ff99_94e375c7360a --> d13948d4_4434_bf78_9916_1ba327123c94 aacb75ae_cb21_6cc8_1f27_e41d2ffa4c34["migratePrefixValue"] c8809718_3b35_1fdb_ff99_94e375c7360a --> aacb75ae_cb21_6cc8_1f27_e41d2ffa4c34 92f2d961_72a4_d195_92d7_2e66972f8894["node"] c8809718_3b35_1fdb_ff99_94e375c7360a --> 92f2d961_72a4_d195_92d7_2e66972f8894 8118fcf2_a51d_d1a1_93d3_c71d3a646692["promises"] c8809718_3b35_1fdb_ff99_94e375c7360a --> 8118fcf2_a51d_d1a1_93d3_c71d3a646692 style c8809718_3b35_1fdb_ff99_94e375c7360a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { __unstable__loadDesignSystem, compile } from '@tailwindcss/node'
import fs from 'node:fs/promises'
import path, { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import { loadModule } from '../../../../@tailwindcss-node/src/compile'
import { resolveConfig } from '../../../../tailwindcss/src/compat/config/resolve-config'
import type { Config } from '../../../../tailwindcss/src/compat/plugin-api'
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
import { error, highlight, relative } from '../../utils/renderer'
import { migratePrefixValue } from './migrate-prefix'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const css = String.raw
export async function prepareConfig(
configFilePath: string | null,
options: { base: string },
): Promise<{
designSystem: DesignSystem
sources: { base: string; pattern: string }[]
userConfig: Config
configFilePath: string
newPrefix: string | null
}> {
try {
if (configFilePath === null) {
configFilePath = await detectConfigPath(options.base)
} else if (!path.isAbsolute(configFilePath)) {
configFilePath = path.resolve(options.base, configFilePath)
}
// We create a relative path from the current file to the config file. This is
// required so that the base for Tailwind CSS can bet inside the
// @tailwindcss-upgrade package and we can require `tailwindcss` properly.
let relative = path.relative(__dirname, configFilePath)
// If the path points to a file in the same directory, `path.relative` will
// remove the leading `./` and we need to add it back in order to still
// consider the path relative
if (!relative.startsWith('.') && !path.isAbsolute(relative)) {
relative = './' + relative
}
let userConfig = await createResolvedUserConfig(configFilePath)
let newPrefix = userConfig.prefix ? migratePrefixValue(userConfig.prefix) : null
let input = css`
@import 'tailwindcss' ${newPrefix ? `prefix(${newPrefix})` : ''};
@config '${relative}';
`
let [compiler, designSystem] = await Promise.all([
compile(input, { base: __dirname, onDependency: () => {} }),
__unstable__loadDesignSystem(input, { base: __dirname }),
])
return {
// ... (74 more lines)
Domain
Subdomains
Dependencies
Imported By
Source
Frequently Asked Questions
What does prepare-config.ts do?
prepare-config.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the UpgradeToolkit domain, Codemods subdomain.
What functions are defined in prepare-config.ts?
prepare-config.ts defines 4 function(s): createResolvedUserConfig, detectConfigPath, parentPaths, prepareConfig.
What does prepare-config.ts depend on?
prepare-config.ts imports 16 module(s): compile.ts, design-system.ts, error, highlight, loadModule, migrate-prefix.ts, migratePrefixValue, node, and 8 more.
What files import prepare-config.ts?
prepare-config.ts is imported by 2 file(s): index.ts, link.ts.
Where is prepare-config.ts in the architecture?
prepare-config.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/prepare-config.ts (domain: UpgradeToolkit, subdomain: Codemods, directory: packages/@tailwindcss-upgrade/src/codemods/template).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free