migrate-postcss.ts — tailwindcss Source File
Architecture documentation for migrate-postcss.ts, a typescript file in the tailwindcss codebase. 10 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 9434c276_afef_dc51_650b_a8b408f077fc["migrate-postcss.ts"] 3570f589_2f69_c1ce_f4d4_16edf9b89280["packages.ts"] 9434c276_afef_dc51_650b_a8b408f077fc --> 3570f589_2f69_c1ce_f4d4_16edf9b89280 9cc0ff32_ad5a_9207_5cc6_12717c5ad23e["pkg"] 9434c276_afef_dc51_650b_a8b408f077fc --> 9cc0ff32_ad5a_9207_5cc6_12717c5ad23e 2329d36e_5aa2_4fa5_cf9f_a9c6cc4e1277["renderer.ts"] 9434c276_afef_dc51_650b_a8b408f077fc --> 2329d36e_5aa2_4fa5_cf9f_a9c6cc4e1277 d3ccc5ce_e370_63df_a97d_a2f004fd83ca["highlight"] 9434c276_afef_dc51_650b_a8b408f077fc --> d3ccc5ce_e370_63df_a97d_a2f004fd83ca 8e778e08_76c6_9ee6_899b_7331b37b18ea["info"] 9434c276_afef_dc51_650b_a8b408f077fc --> 8e778e08_76c6_9ee6_899b_7331b37b18ea 1c806fef_a933_285c_65d9_c10998b12c7d["relative"] 9434c276_afef_dc51_650b_a8b408f077fc --> 1c806fef_a933_285c_65d9_c10998b12c7d a8400c40_f6b4_6c1d_1812_df53f33aaafc["success"] 9434c276_afef_dc51_650b_a8b408f077fc --> a8400c40_f6b4_6c1d_1812_df53f33aaafc f01ffd27_4737_8e3c_147a_bc30c19a4b4d["warn"] 9434c276_afef_dc51_650b_a8b408f077fc --> f01ffd27_4737_8e3c_147a_bc30c19a4b4d b75e8457_6610_e7ce_eeaf_9a1dd10fc510["promises"] 9434c276_afef_dc51_650b_a8b408f077fc --> b75e8457_6610_e7ce_eeaf_9a1dd10fc510 89aef3dd_1eed_c141_d425_b8949215a653["node:path"] 9434c276_afef_dc51_650b_a8b408f077fc --> 89aef3dd_1eed_c141_d425_b8949215a653 f3e20782_7a7a_6d07_0472_a959db30007c["index.ts"] f3e20782_7a7a_6d07_0472_a959db30007c --> 9434c276_afef_dc51_650b_a8b408f077fc style 9434c276_afef_dc51_650b_a8b408f077fc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import fs from 'node:fs/promises'
import path from 'node:path'
import { pkg } from '../../utils/packages'
import { highlight, info, relative, success, warn } from '../../utils/renderer'
// Migrates simple PostCSS setups. This is to cover non-dynamic config files
// similar to the ones we have all over our docs:
//
// ```js
// module.exports = {
// plugins: {
// 'postcss-import': {},
// 'tailwindcss/nesting': 'postcss-nesting',
// tailwindcss: {},
// autoprefixer: {},
// }
// }
// ```
export async function migratePostCSSConfig(base: string) {
let ranMigration = false
let didMigrate = false
let didAddPostcssClient = false
let didRemoveAutoprefixer = false
let didRemovePostCSSImport = false
let packageJsonPath = path.resolve(base, 'package.json')
let packageJson
try {
packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'))
} catch {}
// Priority 1: Handle JS config files
let jsConfigPath = await detectJSConfigPath(base)
if (jsConfigPath) {
let result = await migratePostCSSJSConfig(jsConfigPath)
ranMigration = true
if (result) {
didMigrate = true
didAddPostcssClient = result.didAddPostcssClient
didRemoveAutoprefixer = result.didRemoveAutoprefixer
didRemovePostCSSImport = result.didRemovePostCSSImport
}
}
// Priority 2: Handle package.json config
if (!ranMigration) {
if (packageJson && 'postcss' in packageJson) {
let result = await migratePostCSSJsonConfig(packageJson.postcss)
ranMigration = true
if (result) {
await fs.writeFile(
packageJsonPath,
JSON.stringify({ ...packageJson, postcss: result?.json }, null, 2),
)
didMigrate = true
didAddPostcssClient = result.didAddPostcssClient
didRemoveAutoprefixer = result.didRemoveAutoprefixer
// ... (289 more lines)
Domain
Subdomains
Functions
Dependencies
- highlight
- info
- node:path
- packages.ts
- pkg
- promises
- relative
- renderer.ts
- success
- warn
Imported By
Source
Frequently Asked Questions
What does migrate-postcss.ts do?
migrate-postcss.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the CommandLineInterface domain, Codemods subdomain.
What functions are defined in migrate-postcss.ts?
migrate-postcss.ts defines 7 function(s): detectJSConfigPath, detectJSONConfigPath, isEmptyObject, isSimplePostCSSConfig, migratePostCSSConfig, migratePostCSSJSConfig, migratePostCSSJsonConfig.
What does migrate-postcss.ts depend on?
migrate-postcss.ts imports 10 module(s): highlight, info, node:path, packages.ts, pkg, promises, relative, renderer.ts, and 2 more.
What files import migrate-postcss.ts?
migrate-postcss.ts is imported by 1 file(s): index.ts.
Where is migrate-postcss.ts in the architecture?
migrate-postcss.ts is located at packages/@tailwindcss-upgrade/src/codemods/config/migrate-postcss.ts (domain: CommandLineInterface, subdomain: Codemods, directory: packages/@tailwindcss-upgrade/src/codemods/config).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free