Home / Function/ addTailwindConfigPlugin() — ui Function Reference

addTailwindConfigPlugin() — ui Function Reference

Architecture documentation for the addTailwindConfigPlugin() function in update-tailwind-config.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  b5f29e14_1126_19c7_8749_e1c8e96e8227["addTailwindConfigPlugin()"]
  ef3e192c_eced_bc46_1021_689faf6b7065["update-tailwind-config.ts"]
  b5f29e14_1126_19c7_8749_e1c8e96e8227 -->|defined in| ef3e192c_eced_bc46_1021_689faf6b7065
  bcd6344c_3146_377d_9fd0_f68ae594bdfb["transformTailwindConfig()"]
  bcd6344c_3146_377d_9fd0_f68ae594bdfb -->|calls| b5f29e14_1126_19c7_8749_e1c8e96e8227
  style b5f29e14_1126_19c7_8749_e1c8e96e8227 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/utils/updaters/update-tailwind-config.ts lines 229–265

function addTailwindConfigPlugin(
  configObject: ObjectLiteralExpression,
  plugin: string
) {
  const existingPlugins = configObject.getProperty("plugins")

  if (!existingPlugins) {
    configObject.addPropertyAssignment({
      name: "plugins",
      initializer: `[${plugin}]`,
    })

    return configObject
  }

  if (existingPlugins.isKind(SyntaxKind.PropertyAssignment)) {
    const initializer = existingPlugins.getInitializer()

    if (initializer?.isKind(SyntaxKind.ArrayLiteralExpression)) {
      if (
        initializer
          .getElements()
          .map((element) => {
            return element.getText().replace(/["']/g, "")
          })
          .includes(plugin.replace(/["']/g, ""))
      ) {
        return configObject
      }
      initializer.addElement(plugin)
    }

    return configObject
  }

  return configObject
}

Subdomains

Frequently Asked Questions

What does addTailwindConfigPlugin() do?
addTailwindConfigPlugin() is a function in the ui codebase, defined in packages/shadcn/src/utils/updaters/update-tailwind-config.ts.
Where is addTailwindConfigPlugin() defined?
addTailwindConfigPlugin() is defined in packages/shadcn/src/utils/updaters/update-tailwind-config.ts at line 229.
What calls addTailwindConfigPlugin()?
addTailwindConfigPlugin() is called by 1 function(s): transformTailwindConfig.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free