From c6e4a1b9d76d3d6b877e480f15e8527cb25aa075 Mon Sep 17 00:00:00 2001 From: Adham Farrag Date: Wed, 24 Jan 2024 04:23:38 +0800 Subject: [PATCH] feat: tailwindcss config typescript template --- src/commands/CSS.ts | 9 +++++---- src/templates/css.ts | 17 +++++++++++++++-- src/templates/index.ts | 5 +++-- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/commands/CSS.ts b/src/commands/CSS.ts index 93f5f4e..de86731 100644 --- a/src/commands/CSS.ts +++ b/src/commands/CSS.ts @@ -1,6 +1,6 @@ import { window } from 'vscode' -import { unoCSSConfig, windiCSSConfig, tailwindCSSFile, tailwindCSSConfig, vuetifyConfigFile } from '../templates' -import { isNuxtTwo, createFile, projectSrcDirectory, runCommand, openExternalLink, addNuxtModule, getInstallationCommand } from '../utils' +import { unoCSSConfig, windiCSSConfig, tailwindCSSFile, tailwindCSSJSConfig, tailwindCSSTSConfig, vuetifyConfigFile } from '../templates' +import { isNuxtTwo, createFile, projectSrcDirectory, runCommand, openExternalLink, addNuxtModule, getInstallationCommand, projectRootDirectory } from '../utils' const frameworks = ['TailwindCSS', 'WindiCSS', 'UnoCSS', 'Vuetify'] @@ -80,10 +80,11 @@ const configureTailwind = () => { } if (selections.includes(TailwindOptions.createConfigFile)) { + await createFile({ fileName: `tailwind.config.${isNuxtTwo() ? 'js' : 'ts'}`, - content: tailwindCSSConfig, - fullPath: `${await projectSrcDirectory()}/tailwind.config.js`, + content: isNuxtTwo() ? tailwindCSSJSConfig : tailwindCSSTSConfig, + fullPath: `${projectRootDirectory()}/tailwind.config.${isNuxtTwo() ? 'js' : 'ts'}`, }) } diff --git a/src/templates/css.ts b/src/templates/css.ts index e26ced8..1894172 100644 --- a/src/templates/css.ts +++ b/src/templates/css.ts @@ -12,7 +12,7 @@ export default defineConfig({ }) ` -const tailwindCSSConfig = `/** @type {import('tailwindcss').Config} */ +const tailwindCSSJSConfig = `/** @type {import('tailwindcss').Config} */ module.exports = { content: [], theme: { @@ -22,6 +22,18 @@ module.exports = { } ` +const tailwindCSSTSConfig = `import type { Config } from 'tailwindcss' + +export default > { + content: [], + theme: { + extend: { + } + }, + plugins: [] +} +` + const tailwindCSSFile = `@tailwind base; @tailwind components; @tailwind utilities;` @@ -39,7 +51,8 @@ export default { export { unoCSSConfig, windiCSSConfig, - tailwindCSSConfig, + tailwindCSSJSConfig, + tailwindCSSTSConfig, tailwindCSSFile, vuetifyConfigFile } \ No newline at end of file diff --git a/src/templates/index.ts b/src/templates/index.ts index ca1a19d..4675eb5 100644 --- a/src/templates/index.ts +++ b/src/templates/index.ts @@ -1,5 +1,5 @@ import { eslintConfig, stylelintConfig, stylelintIgnore, eslintIgnore } from './linters' -import { unoCSSConfig, windiCSSConfig, tailwindCSSConfig, tailwindCSSFile, vuetifyConfigFile } from './css' +import { unoCSSConfig, windiCSSConfig, tailwindCSSJSConfig, tailwindCSSTSConfig, tailwindCSSFile, vuetifyConfigFile } from './css' import { nitroDefaultTemplate, nuxtMiddlewareTemplate, @@ -17,7 +17,8 @@ import { appConfigContent } from './appConfig' export { unoCSSConfig, windiCSSConfig, - tailwindCSSConfig, + tailwindCSSJSConfig, + tailwindCSSTSConfig, tailwindCSSFile, vuetifyConfigFile, eslintConfig,