prepareConfig() — tailwindcss Function Reference
Architecture documentation for the prepareConfig() function in prepare-config.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD d1aa21a8_ad44_6ad5_f1e9_8c1f02bbff2d["prepareConfig()"] eb8ababf_fa35_08e1_76f8_c2b2cea868b8["run()"] eb8ababf_fa35_08e1_76f8_c2b2cea868b8 -->|calls| d1aa21a8_ad44_6ad5_f1e9_8c1f02bbff2d 95e0743f_e97d_47fd_9190_ebfac9416c13["detectConfigPath()"] d1aa21a8_ad44_6ad5_f1e9_8c1f02bbff2d -->|calls| 95e0743f_e97d_47fd_9190_ebfac9416c13 85696a99_698d_94e6_aa94_10c070d75965["relative()"] d1aa21a8_ad44_6ad5_f1e9_8c1f02bbff2d -->|calls| 85696a99_698d_94e6_aa94_10c070d75965 c223b5bc_475d_c40f_0314_bed60d87e0a0["createResolvedUserConfig()"] d1aa21a8_ad44_6ad5_f1e9_8c1f02bbff2d -->|calls| c223b5bc_475d_c40f_0314_bed60d87e0a0 b057d93d_6e53_f369_90b0_bb8f3793672e["migratePrefixValue()"] d1aa21a8_ad44_6ad5_f1e9_8c1f02bbff2d -->|calls| b057d93d_6e53_f369_90b0_bb8f3793672e b5593eac_57a1_0ee5_929c_ee4793c6003c["compile()"] d1aa21a8_ad44_6ad5_f1e9_8c1f02bbff2d -->|calls| b5593eac_57a1_0ee5_929c_ee4793c6003c aad2b44f_7d63_9c23_fd06_f010fcd02b2b["error()"] d1aa21a8_ad44_6ad5_f1e9_8c1f02bbff2d -->|calls| aad2b44f_7d63_9c23_fd06_f010fcd02b2b style d1aa21a8_ad44_6ad5_f1e9_8c1f02bbff2d 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