mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-09 06:55:07 +00:00
Support tailwind.config.ts (#1247)
Fixes #659 Fixes #633 Create Next App is using `tailwind.config.ts` in the TypeScript template. Since this is a very common use case it would be nice to preserve the type safety of the file. I added new templates for TypeScript files. I see there is an issue #1073 which asks for ESM support as well. This is not included in this PR. I also fixed the type error in the keyframes that is also handled in #636
This commit is contained in:
@@ -228,12 +228,25 @@ export async function runInit(cwd: string, config: Config) {
|
||||
|
||||
const extension = config.tsx ? "ts" : "js"
|
||||
|
||||
const tailwindConfigExtension = path.extname(
|
||||
config.resolvedPaths.tailwindConfig
|
||||
)
|
||||
|
||||
let tailwindConfigTemplate: string
|
||||
if (tailwindConfigExtension === ".ts") {
|
||||
tailwindConfigTemplate = config.tailwind.cssVariables
|
||||
? templates.TAILWIND_CONFIG_TS_WITH_VARIABLES
|
||||
: templates.TAILWIND_CONFIG_TS
|
||||
} else {
|
||||
tailwindConfigTemplate = config.tailwind.cssVariables
|
||||
? templates.TAILWIND_CONFIG_WITH_VARIABLES
|
||||
: templates.TAILWIND_CONFIG
|
||||
}
|
||||
|
||||
// Write tailwind config.
|
||||
await fs.writeFile(
|
||||
config.resolvedPaths.tailwindConfig,
|
||||
config.tailwind.cssVariables
|
||||
? template(templates.TAILWIND_CONFIG_WITH_VARIABLES)({ extension })
|
||||
: template(templates.TAILWIND_CONFIG)({ extension }),
|
||||
template(tailwindConfigTemplate)({ extension }),
|
||||
"utf8"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user