prepareConfig() — tailwindcss Function Reference
Architecture documentation for the prepareConfig() function in prepare-config.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD ac975fa0_6dfb_5b95_d79d_ea10cebf80a5["prepareConfig()"] c1db9de2_3654_d42b_b9f2_1c5a0ccbd307["run()"] c1db9de2_3654_d42b_b9f2_1c5a0ccbd307 -->|calls| ac975fa0_6dfb_5b95_d79d_ea10cebf80a5 505fd744_81c1_a3d8_bae0_2cbba00f74d3["detectConfigPath()"] ac975fa0_6dfb_5b95_d79d_ea10cebf80a5 -->|calls| 505fd744_81c1_a3d8_bae0_2cbba00f74d3 a4d70660_306b_669c_4b1c_828588c6371c["relative()"] ac975fa0_6dfb_5b95_d79d_ea10cebf80a5 -->|calls| a4d70660_306b_669c_4b1c_828588c6371c 5fced395_cdfc_4802_a67e_74f87df5bfef["createResolvedUserConfig()"] ac975fa0_6dfb_5b95_d79d_ea10cebf80a5 -->|calls| 5fced395_cdfc_4802_a67e_74f87df5bfef 3dfa5e99_766a_d217_730f_6919ba425147["migratePrefixValue()"] ac975fa0_6dfb_5b95_d79d_ea10cebf80a5 -->|calls| 3dfa5e99_766a_d217_730f_6919ba425147 1f83fc7f_b81f_b901_0d0a_48b6bff9e7fa["compile()"] ac975fa0_6dfb_5b95_d79d_ea10cebf80a5 -->|calls| 1f83fc7f_b81f_b901_0d0a_48b6bff9e7fa 98270aaa_96c5_20ee_11bb_e7e96422cda4["error()"] ac975fa0_6dfb_5b95_d79d_ea10cebf80a5 -->|calls| 98270aaa_96c5_20ee_11bb_e7e96422cda4 style ac975fa0_6dfb_5b95_d79d_ea10cebf80a5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-upgrade/src/codemods/template/prepare-config.ts lines 17–71
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 {
designSystem,
sources: compiler.sources,
userConfig,
newPrefix,
configFilePath,
}
} catch (e: any) {
error('Could not load the configuration file: ' + e.message, { prefix: '↳ ' })
process.exit(1)
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does prepareConfig() do?
prepareConfig() is a function in the tailwindcss codebase.
What does prepareConfig() call?
prepareConfig() calls 6 function(s): compile, createResolvedUserConfig, detectConfigPath, error, migratePrefixValue, relative.
What calls prepareConfig()?
prepareConfig() is called by 1 function(s): run.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free